Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 623
  • Last Modified:

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.
0
mike_marquet
Asked:
mike_marquet
  • 6
  • 4
  • 3
  • +1
1 Solution
 
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
 
ShaunWildeCommented:
what do you do in your mousemove handler?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
 
DanRollinsCommented:
hi mike_marquet,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now