?
Solved

Question about COleDropTarget .

Posted on 1998-09-20
5
Medium Priority
?
282 Views
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 !
0
Comment
Question by:demonP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:demonP
ID: 1322363
Edited text of question
0
 
LVL 1

Accepted Solution

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

Author Comment

by:demonP
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 ?

0
 
LVL 1

Expert Comment

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

FORMATETC fmte = {CF_HDROP,(DVTARGETDEVICE FAR *)NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL };
STGMEDIUM medium;
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));
.
}
}
GlobalFree(medium.hGlobal);
This may need a bit of tiding but I hope it helps

0
 

Author Comment

by:demonP
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 !

Regards,
Demon.

0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 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