WM_DROPFILE with multipal files

This topic is 4251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

hello all. i'm using WM_DROPFILE so when ppl drag file to my program i can do somthing.. but what happen whey they drop 2 at the same time? how do i handle that? thanks in advance

Share on other sites
How do you want to handle it? Do you want to do something to both files? Do something with just onen of the files? Display an error if multiple files are dragged onto your application?

Share on other sites
well here is the code i'm using right now:

case WM_DROPFILES:	{       char path[MAX_PATH];    //Path of file    DragQueryFile((HDROP)wParam,0,path,MAX_PATH);   //Attain the path    DragFinish((HDROP)wParam);  //Complete drag-n-drop process

i want that if there are more files then i'll have a matrix (char path[10][MAX_PATH])

and i'll be able to know how many files have been dragged

how do i do that?

p.s my Msgs from windows function looks like this:
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg,WPARAM wParam, LPARAM lParam) {switch (uMsg) // Check For Windows Messages

Share on other sites
To find out how many files were dragged use DragQueryFile() with an iFile parameter of 0xFFFFFFFF. Assuming you are using a C99 compiler that supports variable length arrays you can then just use char path[n][MAX_PATH], where n is the number of files. If that isn't the case, please specify what language you are using.

Share on other sites
Do as SiCrane told you. To get the number of files pass 0xffffffff (-1) and then simply query every filename:

TCHAR     szTemp[MAX_PATH];DWORD dwCount = DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0 );for ( DWORD dwI = 0; dwI < dwCount; dwI++ ){  DragQueryFile( hDropInfo, dwI, szTemp, MAX_PATH );  // do whatever pleases you with szTemp}// do NOT forget thisDragFinish( hDropInfo );