开发者

How to handle drag-and-drop to a Win32 application icon?

开发者 https://www.devze.com 2023-03-20 16:54 出处:网络
I have to update a Win32 application in order to handle the drag-and-drop of files over the icon of the executable.

I have to update a Win32 application in order to handle the drag-and-drop of files over the icon of the executable. I am not sure about how to proceed. A few researches led me to considering the "WM_DROPFILES" message, but MSDN syas it is "Sent when the user drops a file on the window", while I don't want to open a window. Think of a command line tool "MyProgram.exe" : if I drag "MyFile.file" on the windows icon "MyProgram" in the desktop, I wo开发者_StackOverflow中文版uld like it to execute the same way as it would do when typing ">MyProgram MyFile.file" in the command prompt.

Any idea how to achieve this result ?


While it is true that apps get this for free by parsing the command line, there is a shell interface called IDropTarget you can implement if you need more control. See MSDN and this blog entry for more details.


Windows does this for you automatically. Any program foo.exe accepts drags of any file.

Martyn

0

精彩评论

暂无评论...
验证码 换一张
取 消