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 -> FileView ActiveX Control
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

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

When a drag-drop operation occurs over FileView, The OnOnOleDragOver and OnOnOleDragDrop events occur. To get binary/HGLOBAL data from the data object, use the following code :

Code:

// FileView OnOnOleDragDrop event handler
void CErererDlg::OnOnOleDragDropFileviewctrl1(LPDISPATCH Data, long effect, long Button, long Shift, float X, float Y, LPDISPATCH Item, BOOL FAR* DoDefaultShellDropAction)
{
   CFIVDataObject 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 -> FileView ActiveX Control All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group