?
Solved

Drag cursor for CListCtrl & CTreeCtrl

Posted on 1997-06-24
4
Medium Priority
?
967 Views
Last Modified: 2013-11-19
I have drag & drop support implemented in a window containing both a CListCtrl and a CTreeCtrl.  Both of these are using image lists to show icons for each item.  I can drag items from one to the othe without any difficulty.

The problem I am having is that I cannot figure out how to provide the proper drag cursor for the operation.  All I get is the default drag cursor with a small empty box, an arrow, and possibly a shortcut box.  I don't know what to hook to provide this.  I thought it would have worked by default since I am using the image list and all.
0
Comment
Question by:Vance Kessler
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1302274
I assume you're using CreateDragImage() to get the ghost of the dragged item. What you're probably not doing is calling SetCursor() with the appropriate cursor. You can use any cursor for your drag, but be sure to call SetCapture().

Also, catch MouseMove messages and set the cursor there too if you want to provide feedback on whether or not dropping is alllowed.

When you're done (catch LBUTTONUP), then you can set the cursor back to the original cursor and ReleaseCapture().


0
 

Author Comment

by:Vance Kessler
ID: 1302275
No I am not using CreateDragImage().  I don't know where to use it!  I have overridden OnDragOver(), OnDragEnter(), OnDragLeave(), and OnDragBegin().  These provide enough for the drag & drop to work but not enough for the correct cursor.

I tried to override WM_MOUSEMOVE in the View, but the problem is that I never get mouse move messages.  They are all going to the actual tree control or list control.
0
 

Expert Comment

by:rderaed
ID: 1302276
Type CListCtrl in the Help dialog. Have a look in the "See Also" combobox and Select the Drag and Drop
sample. Copy it on your drive and have a look. All the
mecasnism is in the sample.

After trying for 1 day the drag and drop, i Found this sample
and understood it in few minutes...

Microsoft is the best expert ;-)


0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1302277
You should not catch WM_MOUSEMOVE in the view, because the message will only go to the window that has called SetCapture. In this case, it would be the CTreeCtrl. You can call SetCursor() and CreateDragImage from your handler of OnDragBegin().


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question