My question is related to the aspect of drag and drop in MFC programming.
I know there are four classes (
)which can realize the function of drag and drop. Data sources (as implemented by
objects) represent the source side of the data transfer. Data objects (as implemented by
objects) represent the destination side of the data transfer.The
provides the communication mechanism between a window and the OLE libraries.To get a window to accept drop commands, you should first create an object of the
class, and then call the Register function with a pointer to the desired
object as the only parameter.
class handles the receiving portion of the drag-and-drop operation. The
object is responsible for determining when a drag operation begins, providing feedback during the drag operation, and determining when the drag operation ends.
The drop effects are like this:
Drop target cannot accept the data. Corresponding cursor is
Drop results in a copy. The original data is untouched by the drag source. Corresponding cursor is
: Drag source should remove the data. Corresponding cursor is
: The data will be "linked to" by the drop target. Corresponding cursor is
These cursors are not displayed. But i am sure you know them also.These cursors are default cursors when drop and drop.
Now i want to change them with my own cursors. I can change these default cursors through the
function. The specification of the function is described in MSDN.
Here is the part of my codes to change the default cursor.
1.override the class of
and the related function
class CDropSource: public COleDropSource
SCODE GiveFeedback(DROPEFFECT dropEffect);
virtual SCODE QueryContinueDrag(BOOL bEscapePressed, DWORD dwKeyState);
virtual BOOL OnBeginDrag(CWnd* pWnd);
SCODE CDropSource::GiveFeedback(DROPEFFECT dropEffect)
return m_bDragStarted ? DRAGDROP_S_USEDEFAULTCURSORS : S_OK;
2.pass the member of CDropSource to the COleDataSource::DoDragDrop function when beginning drag
source.CacheGlobalData(m_nformat, hData );
GlobalFree( hData );
Now the question is here. There are two situations.
First,if the window is registered as the
window,then changing default cursor in
function is in effect and the four default cursors are can be changed.
Second, if the window is not registered as the COleDropTarget window, then the parameter value of
function is DROPEFFECT_NONE. And now the default cursor can not be changed, the
function is of no effect.
And how can i change the default cursor in the second situation?
My english is bad, i wish you can understand my meaning above. Thanks very much.
The question has been uploaded for one days,but there has no answer for the question. I believe that there must be somebody who can resolve this simple question. I really need your help. Thanks a lot.
I updated the format of your question to make it "readable".