Solved

Register Drag and Drop in Windows

Posted on 2010-09-08
4
398 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

632 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