tags:

views:

36

answers:

2

Hi I have an Application and want to drop a file in it. I used the COleDropTarget class and derived from it. In my CMainFrame class in the methode OnCreate I register it. This return true.

When OnDrop gets called pDataObject->GetFileData(CF_TEXT); or even pDataObject->IsDataAvailable(CF_TEXT) returns 0.

Can someone tell me why?

Thanks

A: 

Dropping a file doesn't have the data type CF_TEXT but CF_HDROP. You have to check for that and then extract the file paths from the CF_HDROP structure.

To get the paths from the CF_HDROP structure, use the DragQueryFile API.

Stefan
Thanks for your answer.I did what you told and IsDataAvailable return 1. thats good.But how do I extract data from CF_HDROP? (Because this is defined as 15 in winuser.h and not a structure)and after this CFile* file =pDataObject->GetFileData(CF_HDROP);file->m_strFileName has the value ""
edited my answer with a hint about DragQueryFile
Stefan
A: 

Thanks for your answer. I did what you told and IsDataAvailable return 1. thats good. But how do I extract data from CF_HDROP? (Because this is defined as 15 in winuser.h and not a structure) and after this: CFile* file =pDataObject->GetFileData(CF_HDROP); file->m_strFileName has the value ""