Solved

Register Drag and Drop in Windows

Posted on 2010-09-08
4
382 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 500 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now