Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Drop Files
Author:Arkon
Category:Win32API
File Size:749 Bytes
Uploaded at:27-Nov-02 02:43:15 pm
Description:
  A two steps guideline which shows how to use this neat feature in your own windows.
  
In order to get dropped files(AKA: file(s) which were dragged onto the window control)
you'll have to accomplish two steps:
Note that the DragQueryFile also retrieves directories!

1.Add the accept-files style to the window control
 
 DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
 SetWindowLong(hWnd, GWL_EXSTYLE, dwStyle | WS_EX_ACCEPTFILES);

2.In the window procedure proccess the WM_DROPFILES message

 char tmp[256];
 case WM_DROPFILES:
  HDROP hDrop = (HDROP)wParam;
  DWORD DropsNo = DragQueryFile(hDrop, -1, NULL, 0);
  for (DWORD i = 0; i < DropsNo; i++)
  {
   DragQueryFile(hDrop, i, tmp, 256);
   MessageBox(NULL, tmp, "", MB_OK); // Do anything with the data...
  }
  DragFinish(hDrop);
 return(0);

Voila :)
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[106235]
2D Rotated Rectangles Collision Detection[79393]
Keyboard Hook[68783]
UDP[52867]
HTTP Proxy[36098]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10613]
PS2 Mouse Driver[6098]
Wave Format Player[4984]
Reading FAT12[4870]
CodeGuru[4561]


All rights reserved to RageStorm © 2009