Solved

Register Drag and Drop in Windows

Posted on 2010-09-08
4
394 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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.
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.

734 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