Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Drag and drop with CExtTreeGridWnd Collapse All
Subject Author Date
Krustys Donuts Apr 24, 2008 - 12:02 PM

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;

}

 

Technical Support Apr 25, 2008 - 10:04 AM

And again, please check whether you initialized the OLE library correctly as we said in our answer to your previous message. Please also take a look at this test project.