更新时间:2023-10-20 16:27:40
AFAIK,默认情况下,控制台窗口不支持拖放.您始终可以使用自己的消息循环创建自己的单独弹出窗口,以便用户可以将项目拖到上面.
AFAIK, a console window does not support drag&drop by default. You can always create your own separate popup window with its own message loop so the user has something to drag items onto.
To use drag&drop on the console window itself, try using GetConsoleWindow()
to get the console HWND, then either:
使用 SetWindowSubClass()
,然后使用
subclass the HWND using SetWindowLong/Ptr()
or SetWindowSubClass()
, then register the HWND using DragAcceptFiles()
to start receiving WM_DROPFILES
messages. Be sure to call DragAcceptFiles()
again to stop receiving the messages and then unhook your subclass before exiting the app.
实现 IDropTarget
接口,然后使用 RevokeDragDrop()
退出应用程序.
implement the IDropTarget
interface and then register the HWND using RegisterDragDrop()
to start receiving notifications. Be sure to call RevokeDragDrop()
before exiting the app.
WM_DROPFILES
易于编码,但是 IDropTarget
更加灵活,因为它可以处理虚拟项目和物理文件.
WM_DROPFILES
is easier to code for, but IDropTarget
is more flexible as it handles virtual items as well as physical files.