Question about COleDropTarget .

Posted on 1998-09-20
Last Modified: 2013-11-19
Environment: Win95 OSR2 & VC++5

Hi all,
     I have a question about using COleDropTarget to
make a drop-file support app .  My question is ,when a
drag-drop operation is over how to get the file's name
and path in the OnDrop() function ?
     Although I can handle the WM_DROPFILES to get
what I want , I think there also should be these infos in the COleDataObject type object come along with the OnDrop()
function .  

      I'v made below call :
CFile *pFile = pDataObject->GetFileData(CF_HDROP);

It seemed successful and return a value , but I can't get the file's name and path with :  pFile-> GetFilePath () .

      Did I do something wrong ? Can anyone tell me the correct method to do this ?

      Any idea will be greatly appreciated !
Question by:demonP
  • 3
  • 2

Author Comment

ID: 1322363
Edited text of question

Accepted Solution

Andy_Keys earned 50 total points
ID: 1322364
You use the DragQueryFile to get fileneme from the CF_HDROP struct.

Author Comment

ID: 1322365
Hi Andy,
   Thanks for your answer , could you explain it
more clearly ?
   DragQueryFile() can just accept HDROP handle as
parameter , how can I get it in OnDrop() function ?


Expert Comment

ID: 1322366
Sorry I was a bit vague
try something like

unsigned int a, uiFiles

HRESULT hres = pDataObject->GetData(this->_pdtobj, &fmte, &medium);
if (SUCCEEDED(hres))
HDROP hdrop = medium.hGlobal;
uiFiles = DragQueryFile(hdrop, (UINT)-1, NULL, 0);
char szFile[MAX_PATH];
char szBuf[MAX_PATH*2+64];
//now loop to get the individual names
for(a =0; a < uiFiles; a++ )
DragQueryFile(hdrop, a, szFile, sizeof(szFile));
This may need a bit of tiding but I hope it helps


Author Comment

ID: 1322367
Hi Andy,
     I have tried your code , it worked very well .
But it seemed I found a relatively simple method to
do it .

    I just called:
hDropFile = (HDROP)GetGlobalData(CF_HDROP);

Now the handle can be used by DragQueryFile() and
everything is OK ,too .

    Thank you for the answer !



Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 53
notReplace  challenge 53 116
abstract class with all non abstract mentods 6 76
Use of condition with 'serial' in ansible 2 50
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now