Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Register Drag and Drop in Windows

Posted on 2010-09-08
4
Medium Priority
?
404 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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.
Suggested Courses

730 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