Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1059891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:14:32+00:00 2026-05-16T18:14:32+00:00

I am using C#’s inbuilt drag and drop via Control.DoDragDrop(). I use an Image

  • 0

I am using C#’s inbuilt drag and drop via Control.DoDragDrop(). I use an Image List and ImageList_DragMove and friends to move a semi-transparent image around, tracking with the mouse. (See my reply in this thread for more information). How can I make the ImageList track the mouse when it is outside my windows? I only receive mouse position messages in OnDragOver(), and only when the mouse is over one of my Windows. The drag is going to another instance of my application, and I would like the ImageList to go the whole way, including over the desktop. I guess the basic problem is that DoDragDrop runs its own little message loop.

Windows Explorer gets this done so I know it is possible. I suppose I could start a thread to keep track of the mouse or write my own drag/drop message loop, but I am hoping for an easier way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:14:32+00:00Added an answer on May 16, 2026 at 6:14 pm

    You cannot draw outside your own windows. The way to do this is by changing the mouse cursor. That’s what the GiveFeedback event is available, set e.UseDefaultCursors to false and set the Cursor.Current.

    Just to give you an idea what this looks like, here’s a sample form that drags visible text. Alter it to draw the bitmap the way you want it, from your ImageList for example. Beware that Bitmap.GetHicon() does not create great icons, the color mapping is poor.

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            this.GiveFeedback += Form1_GiveFeedback;
        }
    
        void Form1_GiveFeedback(object sender, GiveFeedbackEventArgs e) {
            string txt = "Dragging text";
            SizeF sz;
            using (var gr = this.CreateGraphics()) {
                sz = gr.MeasureString(txt, this.Font);
            }
            using (var bmp = new Bitmap((int)sz.Width, (int)sz.Height)) {
                using (var gr = Graphics.FromImage(bmp)) {
                    gr.Clear(Color.White);
                    gr.DrawString(txt, this.Font, Brushes.Black, 0, 0);
                }
                bmp.MakeTransparent(Color.White);
                e.UseDefaultCursors = false;
                IntPtr hIcon = bmp.GetHicon();
                Cursor.Current = new Cursor(hIcon);
                DestroyIcon(hIcon);
            }
        }
        protected override void OnMouseDown(MouseEventArgs e) {
            this.DoDragDrop("example", DragDropEffects.Copy);
        }
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        extern static bool DestroyIcon(IntPtr handle);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.