I would like to implement drag and drop functionality such that the user is able to drag a row in a CExtTreeGridWnd onto another row of the same view and have the two rows combine.
In OnCreate, the window is registered as a drop target and the data format is defined. The appropriate override of OnGbwDataDndIsAllowed has been implemented. In the override of OnGbwDataDndDo a COleDataSource object is created and its DoDragDrop method is called. This code is shown below.
Although I do get a call to OnGbwDataDndDo, I never get a call to OnDragEnter, OnDragLeave, OnDragOver or OnDrop. Am I missing something?
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void VRTeachpointGrid::OnGbwDataDndDo(const CExtGridHitTestInfo & htInfo)
{
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(VRApproOrientation));
VRApproOrientation* pAo = (VRApproOrientation*)::GlobalLock(hData);
VRApproOrientation ao;
*pAo = ao;
::GlobalUnlock(hData);
COleDataSource ods;
ods.CacheGlobalData(m_nDnDFormat, hData);
DROPEFFECT de = ods.DoDragDrop(DROPEFFECT_MOVE | DROPEFFECT_SCROLL);
if (de == DROPEFFECT_MOVE)
{
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
DROPEFFECT VRTeachpointGrid::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
return OnDragOver(pDataObject, dwKeyState, point);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void VRTeachpointGrid::OnDragLeave()
{
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
DROPEFFECT VRTeachpointGrid::OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
return DROPEFFECT_MOVE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL VRTeachpointGrid::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int VRTeachpointGrid::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CExtTreeGridWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_oleDropTarget.Register(this);
m_nDnDFormat = ::RegisterClipboardFormatA(_T("VRApproachOrientations"));
return 0;
}