Drag and Drop animation

srelu

Member
Joined
Nov 5, 2007
Messages
14
Programming Experience
Beginner
I tried unsuccessfully to figure out how can be achieved the following behaviour of the Windows Explorer:
When you drag a file/directory (one or more), a transparent image showing the icons and and their names moves together with the cursor.

My question is how this behaviour can be achieved in VB.NET. A solution in VB.NET is not a madatory requirement, it can be VC++ as well, I just switched from VC++ to VB.NET.
 
GiveFeedback event is used for drop targets, here you can set "e.UseDefaultCursors = False" and assign a cursor you draw yourself. There is an example to draw a cursor in this thread. Sometimes you may want to set AllowDrop for example for form itself even if it really isn't a drop target, just to give a steady cursor feedback during the dragdrop operation. So you would examine the filedrop list and get associated icons so you can draw them to the cursor image, try this IconExtractor class.
 
JohnH, thanks for your suggestions I appreciate your attention, but the question wasn't about the drag and drop cursor, it was about the transparent image of the files moving together with the cursor.

The rest of the code including cursor handling is already written and works fine.

It's unclear to me what should I achieve with the IconExtractor class. I can obtain an image of the selected files and their icons with Graphics.CopyFromScreen.

(If you need the associated icons there is no need for that class, you can invoke directly the ExtractAssociatedIcon method.)
 
It is unclear to me now what you ask, what I described is how dragdrop in Explorer is implemented, and it is how you implement it in your own application.

Icon.ExtractAssociatedIcon Method was new in .Net 2.0, I didn't know of that, thanks for mentioning it!
 
Sorry for the quality of the attached image that's all I was able to achieve with my camera. (Print screen was out of question because it hides the cursor.)
There are two open windows in the picture. In the left side is the Internet Explorer, in the right side is a Windows Explorer window. You can notice in the right side three selected files. Right in the middle of the image (in the ellipse) you can see the dragging of these three files in action.
I dont care about the cursor (arrow), what I'm interrested in is that transparent bluish image of the three files and their icons (highlited with the ellipse). The standard drag and drop is without that image, I try to figure out how can that image be obtained and handled. (Well, the handling is the problem, I can obtain the image easily.)

p.s. If you go back to my first post in the thread, an read it carefully weighting each word, you'll see that that's what I asked from the begining.
 

Attachments

  • Pic.jpg
    Pic.jpg
    44.7 KB · Views: 41
Read the reply (post 2) again. The dragdrop cursor is the whole image thing you see with file icons and names and everything, one big cursor image.
 
I don't think it's that way. I'm not sure you can create a cursor that big. (But if it's possible, explain me how and I will be grateful.)

Experiment: select a grop of files and drag them quckly, (and erratically) over the screen. You will notice a small delay between the movement of the cursor and the movement of the transparent image. That proofs that they are different graphic objects.
(Supposition: the experiment may fail if your computer is very fast and you have a high performance video card.)

Added later: The experiment works better with small and slow cursor movement.
 
Last edited:
It is that way. You already know how to draw the cursor, see the link post 2.
 
Back
Top