I have implemented my custom drag&drop by deriving from COleDataSource and COleDropTarget. Everythings work fine but I have an scenario that makes the application crashes.
That happens when the dialog where the drag&drop controls are placed is destroyed while the user is in the middle of a drag&drop operation. This is not usual because normally to close a dialog the user have to use the mouse or the keyboard and then the drag&drop operation is automatically canceled. But in this scenario the dialog can be closed due to an external condition (a custom message that changes the view) and then the drap&drop operation is not canceled.
So my question is, how can I programmatically cancel the drag&drop operation? The operation is started from the OnLButtonDown message handle calling COleDataSource::DoDragDrop.
Update:
I've implemented using DelayRender and it continues crashing. These are the two asserts I am getting:
- When the mouse pointer (while dragging) is inside a control that is a COleDropTarget-derived class.
The assert is in the Revoke method and this is the line:
ASSERT(m_lpDataObject == NULL);
- When the mouse pointer is not inside a COleDropTarget-derived class.
In this case the assert is in the destruction of the COleDataSource (in fact it is in its parent class CCmdTarget). In this line:
ASSERT(m_dwRef <= 1);
Thanks in advance!