Jump to content
  • Advertisement
Sign in to follow this  
mc30900

WM_DROPFILE with multipal files

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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?

thanks in advance

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 this post


Link to post
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 this post


Link to post
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 this
DragFinish( hDropInfo );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!