Solved

Changing cursor in drag'n drop using COleDropTarget !

Posted on 2001-06-20
15
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

734 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