Re: Drag and Drop Sticks...
Quote:
However, after the drop, the mouse cannot be used for a while.
What does this mean? Does the application stop responding? Or, is the mouse cursor shape not returning to an arrow? It would help if you posted some code to show what you've done.
Re: Drag and Drop Sticks...
Hi,
The cursor is the normal one, but if I try to click on some buttons then nothing happens. If I click the button, hold it down and move it a bit, the cursor then changes to the "+" in a square, just as when initially howering over a window area that supports the drop of that format.
The following code is of three overidden methods of a class derived from COleDropTarget.
Code:
DROPEFFECT CMyDrop::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
//if the data is the kind we want
if(pDataObject->IsDataAvailable(CF_PRIVATEFIRST))
{
return DROPEFFECT_COPY | DROPEFFECT_MOVE;
}
//we can't handle this type of data
return DROPEFFECT_NONE;
}
DROPEFFECT CMyDrop::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
if(pDataObject->IsDataAvailable(CF_PRIVATEFIRST))
{
return DROPEFFECT_COPY | DROPEFFECT_MOVE;
}
return DROPEFFECT_NONE;
}
void CLoopDrop::OnDragLeave(CWnd* pWnd)
{
//we can use this method to do any kind of clean up
//in this case, we don't have anything
}
BOOL CMyDrop::OnDrop( CWnd* pWnd,
COleDataObject* pDataObject,
DROPEFFECT dropEffect,
CPoint point)
{
BOOL Ret = FALSE;
if (pDataObject->IsDataAvailable(CF_PRIVATEFIRST))
{
HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_PRIVATEFIRST);
//Get the short that was dragged and store it locally for testing
short nTheValue = 0;
memcpy(&nTheValue, GlobalLock(hGlobal), sizeof(short));
GlobalUnlock(hGlobal);
Ret = TRUE;
}
return Ret;
}
the following code is how I start the drag
Code:
COleDataSource dataSource;
HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE,sizeof(short));
short* pShort = (short*)GlobalLock(hData);
*pShort = 69;
GlobalUnlock(hData);
if(hData)
{
//attach the data to the COleDataSource Object
dataSource.CacheGlobalData(CF_PRIVATEFIRST, hData);
//allow the user to drag it
DROPEFFECT DropEffect = dataSource.DoDragDrop();
}
Thanks again :)
Re: Drag and Drop Sticks...
What type of object starts the drag and drop operation? Is is a control or a window? Do you start it in the OnLButtonDown() handler?
Re: Drag and Drop Sticks...
It is a dialog that contains an object derived from CButton. On OnLButtonDown the custom button fires a message which is captured by the parent dialog. The parent dialog then calls a member function which contains the code you saw above.
Re: Drag and Drop Sticks...
Are you executing the base class call for OnLButtonDown(). Your problem symptoms imply that you're not completing some code.
Re: Drag and Drop Sticks...
Yes I call
Code:
CButton::OnLButtonDown(nFlags, point);
in the function that handles the OnLButtonDown message, before sendning a custom message to the parent. It does seem like some code somewhere is incomplete but I cannot see it being in the custom button. It is probably, in the Drag and Drop code, even though it seems right too.
I will think a bit more about it .. will let you know on any new information.
Thanks!