Solved

Drag cursor for CListCtrl & CTreeCtrl

Posted on 1997-06-24
4
944 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now