Changing cursor in drag'n drop using COleDropTarget !

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.
mike_marquetAsked:
Who is Participating?
 
DanRollinsConnect With a Mentor Commented:
hi mike_marquet,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
ShaunWildeCommented:
override OnDragOver and select the cursor you want when you return from this override
0
 
mike_marquetAuthor Commented:
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
ShaunWildeCommented:
what do you do in your mousemove handler?
0
 
mike_marquetAuthor Commented:
I do nothing in the WM_MOUSEMOVE handler.
The only thing is that the target window is a custom control.
0
 
MaheshSundararamanCommented:
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
 
ShaunWildeCommented:
> 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
 
mike_marquetAuthor Commented:
It's the same.

I have MAKEINTRESOURCE but have forgotten to write it here in the question.
0
 
ShaunWildeCommented:
> It's the same.

damn - while I am stumped without more code - what you are doing seems right
0
 
MaheshSundararamanCommented:
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
 
DanRollinsCommented:
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
 
mike_marquetAuthor Commented:
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
 
ShaunWildeCommented:
> 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
 
ShaunWildeCommented:
yup - looks like DanRollins might be right - there is a sample called drag95.exe in the msdn which could be of help


0
 
DanRollinsCommented:
>>...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
All Courses

From novice to tech pro — start learning today.