Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Register Drag and Drop in Windows

Posted on 2010-09-08
4
Medium Priority
?
418 Views
Last Modified: 2012-05-10
Hi, is it possible to Register Drag and Drop to my Application instead of Windows Move/Copy??

if so what would the registry paths and values be?
0
Comment
Question by:eNarc
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 33629312
No registry entries are involved here - you have to set 'WS_EX_ACCEPTFILES' (see http://msdn.microsoft.com/en-us/library/61fe4bte.aspx - "Extended Window Styles") for the window that wull accept drag/drop actions and call 'DragAcceptFiles(hWnd, TRUE);' (http://msdn.microsoft.com/en-us/library/bb776406%28VS.85%29.aspx) when handling 'WM_CREATE'. When this is done, you will receive a 'WM_DROPFILES' message (http://msdn.microsoft.com/en-us/library/bb774303%28VS.85%29.aspx) when a user drops files on that window. Handling that message would be like
char       szFile[80];      // Used to store name of dropped file
WORD       wNumFiles, cb;

case WM_DROPFILES:
   // Retrieve number of dropped files
   wNumFiles = DragQueryFile((HANDLE)wParam, 0xFFFF, NULL, 0);

   // Simple case of one dropped file; more than one can be dropped
   if (wNumFiles == 1)
      {
      cb = DragQueryFile((HANDLE)wParam, 0, szFile, 80);

      // If no characters copied, there were no files
      if (cb == 0)
         return(0L);

      // now you have the file's name, do something with it.

      DragFinish((HANDLE)wParam);
      }

Open in new window

0
 
LVL 5

Author Comment

by:eNarc
ID: 33629478
is this for replacing the Copying and moving so that when I move a file to another folder it will open my program instead?

or is that to drop files into the program?

or is that for when windows issues the loading of the program

how does one get the From and To paths? when moving a file to another folder?
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 33629577
That is when files are dropped on your application. If you want to monitor what happens in the explorer, you will need tn 'ICopyHook' (http://msdn.microsoft.com/en-us/library/bb776049%28VS.85%29.aspx). See also http://msdn.microsoft.com/en-us/library/cc144063%28VS.85%29.aspx ("Creating Copy Hook Handlers")
0
 
LVL 5

Author Comment

by:eNarc
ID: 33629664
yea, a hook is what I'm after :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

783 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