Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO: Access binary data from dataobject in C++ during drag-drop

 
Subscribe to the RSS feed for this forum  Forum Index -> FolderView ActiveX Control
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Fri Jan 16, 2009 11:15 am    Post subject: HOWTO: Access binary data from dataobject in C++ during drag-drop

When a drag-drop operation occurs over FolderView, The OnOnOleDragOver and OnOnOleDragDrop events occur. To get binary/HGLOBAL data from the data object, use the following code :
Code:
// FolderView OnOnOleDragDrop event handler
void CFdrViewVCDlg::OnOnOleDragDropFolderviewctrl1(LPDISPATCH Data, long effect, long Button, long Shift, float x, float y, LPDISPATCH Node, BOOL FAR* DoDefaultShellDropAction)
{
 CFOVDataObject dataObject;
 dataObject.AttachDispatch(Data,FALSE);
   
 UINT cfFormat = ::RegisterClipboardFormat("<<custom data format>>"); // our custom data format
 if (dataObject.GetFormat(cfFormat)) // Is data in that format present
 {
  // Get the data
  VARIANT varBytes = dataObject.GetBinary(cfFormat);
 
  //Binary data is stored in the variant as an array of unsigned char
  if(varBytes.vt == (VT_ARRAY|VT_UI1))  // (OLE SAFEARRAY)
  {
            void *pArrayData;
   
            //Obtain safe pointer to the array
            SafeArrayAccessData(varBytes.parray,&pArrayData);
   
            // Use data
            // ...
            // ...             
   
            //Unlock the variant data
            SafeArrayUnaccessData(varBytes.parray);   
  }
 
  VariantClear(&varBytes);       
 }

}
Back to top
Display posts from previous:   
Forum Index -> FolderView ActiveX Control All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group