Solved

Changing cursor in drag'n drop using COleDropTarget !

Posted on 2001-06-20
15
581 Views
Last Modified: 2013-11-20
Hi,

I'm using COleDropTarget to perform a drag'n drop operation between a list control and a custom control.
When I start dragging the cursor is a circle with a line when target is not accepted or an arrow with a plus sign when target is accepted.

How can I dynamically changed this cursor at any time while dragging is in progress ?

I want to do this because, depending of dragged info, the target is the full window or only a portion of this target window.
0
Comment
Question by:mike_marquet
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6210660
override OnDragOver and select the cursor you want when you return from this override
0
 

Author Comment

by:mike_marquet
ID: 6210886
I have always try it but the cursor is not changed.

source sample :

DROPEFFECT CTLOleDropTarget::OnDragOver(CWnd *pWnd, COleDataObject *pDataObject, DWORD dwKeyState, CPoint point)
 {
  SetCursor(LoadCursor(AfxGetInstanceHandle(),IDC_MYICON));

  if (!CANDROP) return DROPEFFECT_NONE;

  return m_stCurrentDropEffect;
 }
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6211117
what do you do in your mousemove handler?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:mike_marquet
ID: 6213349
I do nothing in the WM_MOUSEMOVE handler.
The only thing is that the target window is a custom control.
0
 
LVL 2

Expert Comment

by:MaheshSundararaman
ID: 6213982
Dear Mike

Iam not so sure but try this line instead

SetCursor(LoadCursr(MAKEINTRESOURCE(IDC_MYICON1))

And the other i guess move the cant drop condition before the SetCursor..and say what happens

Mahesh
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6214134
> Iam not so sure but try this line instead

doh! - you're right that line is wrong he should have what you gave or

SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_MYICON) ));



 
0
 

Author Comment

by:mike_marquet
ID: 6214372
It's the same.

I have MAKEINTRESOURCE but have forgotten to write it here in the question.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6214580
> It's the same.

damn - while I am stumped without more code - what you are doing seems right
0
 
LVL 2

Expert Comment

by:MaheshSundararaman
ID: 6215439
Mike did u create a cursor resource or icon resource..

hmm try creating a cursor resource and give a valid name like IDC_<cursor_name>

then in Open the resource in edit mode ..where we can see the code..and check if the changes made had been updated

Mahesh
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6216904
SetCursor is no good here.  You need to call SetDragCursorImage() -- a member of a CImageList that you created when the drag began.

In OnMouseMove from the drag source, call a custom-designed HitTest() fn to get feeback from the target.

This article describes the process and provides source code.  I implemented it for drag from list to tree without too much head scratching.

http://www.microsoft.com/MSJ/0898/wicked0898.htm

-- Dan
0
 

Author Comment

by:mike_marquet
ID: 6217286
OK, I will try it as soon as possible.

P.S. : When I set the cursor in the OnDragOver function, the cursor becomes visible but is directly replaced by the default one.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6217383
> SetCursor is no good here.  You need to call
> SetDragCursorImage() -- a member of a CImageList that you
> created when the drag began.

why is that ? I'll have to admit the last time I did any drag and drop was in windows 3.11 days and we never had SetDragCursorImage - we could only use SetCursor

0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6217404
yup - looks like DanRollins might be right - there is a sample called drag95.exe in the msdn which could be of help


0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6219349
>>...DanRollins might be right...
I was wrong once, back in 1983.  For a period of nearly an hour, I *erroneously thought I'd made a mistake*.  It turned out that I had not, but I've been insecure ever since.

-- Dan
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 6307023
hi mike_marquet,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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