Solved

Changing cursor in drag'n drop using COleDropTarget !

Posted on 2001-06-20
15
557 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
Comment Utility
override OnDragOver and select the cursor you want when you return from this override
0
 

Author Comment

by:mike_marquet
Comment Utility
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
Comment Utility
what do you do in your mousemove handler?
0
 

Author Comment

by:mike_marquet
Comment Utility
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
Comment Utility
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
Comment Utility
> 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
Comment Utility
It's the same.

I have MAKEINTRESOURCE but have forgotten to write it here in the question.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
> 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
> 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
Comment Utility
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
Comment Utility
>>...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
Comment Utility
hi mike_marquet,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

14 Experts available now in Live!

Get 1:1 Help Now