Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to implement drag and drop in my listview control so I can rearrange items.

I want to use system default cursors to indicate when drop is/isn't allowed.

I have checked documentation for LoadCursor[^] function and have found nothing.

The best resemblance I could find was for the case when drop is not allowed -> IDC_NO has the same look as the cursor in OLE drag and drop, but it is red ( I have tested this on my Windows 7).

QUESTION:

How to use LoadCursor (or some similar function) to load default cursors used in OLE drag and drop?
Posted
Updated 25-Feb-15 17:19pm
v2

1 solution

How about cursors found in ole32.dll?
Cursor-group 1 contains a black circle with a line through it.
Cursor-group 6 contains an arrow, a box with a dotted outline and a page with a + on it.

This will grab the drop icon.
C++
HMODULE oleMod = LoadLibrary("ole32.dll");
mCursor = LoadCursor(oleMod, MAKEINTRESOURCE(6));


According to Hans Passant here: http://stackoverflow.com/questions/3617862/custom-made-win32-drag-drop-cant-get-change-invalid-slashed-circle-cursor[^] OLE takes control of the cursor when doing an *OLE* d&d. It seems reasonable to guess that it grabs the cursors it uses from its own dll. :)
 
Share this answer
 
Comments
AlwaysLearningNewStuff 12-Mar-15 11:13am    
When can I free the library? Can I do it immediately after mCursor = LoadCursor(oleMod, MAKEINTRESOURCE(6)); or just before my program exits ( just below message loop)?

BTW, I really could use help with the following issue: http://www.codeproject.com/Questions/885784/Cant-get-LVHT-ABOVE-LVHT-BELOW-LVHT-TORIGHT-LVHT-T?arn=0

Best regards.
enhzflep 16-Mar-15 3:59am    
I imagine you can do so immediately after loading the cursor as you suggest, though haven't the time to test or research this currently.

No problem, I'll take a look at the question you mention. :)
Cheers. :)
enhzflep 18-Mar-15 9:31am    
Just wanted to expand upon my previous comment, think about using LoadImage to load a picture. Once loaded, you can actually rename or delete the original file on disk - I'm almost certain that there is no need to maintain a handle to the library for just the same reason - the data is read into freshly allocated memory and no longer relies on the original image - though, exceptions exist for some of the image formats that GDI+ can load.

----

Also, still thinking about the other question - determining if the header is the target is trivial with the use of WindowFromPoint and GetClassName. I also had inconsistent results with your code, even when repeatedly clicking on the exact same header column.

:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900