winapi - 对话框可以拦截传递给其控件的拖放消息吗?

标签 winapi mfc drag-and-drop

如果对话框将其某些控件注册为放置目标,则用于这些控件的拖放消息将通过对话框的消息处理传递,以便对话框可以注册消息处理程序以通知/拦截这些消息消息?

以与此问题类似的方式,我希望在某些情况下在调用各个拖放处理程序之前捕获更高级别的拖放事件。但这个问题的答案表明这实际上不可能? How to disable drag/drop when a dialog box is open

最佳答案

If a dialog registers some of its controls as drop-targets, will drag'n'drop messages intended for those controls pass through the dialog's message processing in a way that the dialog can register a message handler to be notified/intercept those messages?

如果控件使用DragAcceptFiles(),则WM_DROPFILES消息将直接转到各个控件的窗口过程,而不是对话框的窗口过程。如果要拦截消息,则必须使用 SetWindowLongPtr()SetWindowSubClass() 对各个控件进行子类化,或者使用 SetWindowsHookEx( )

如果控件使用 RegisterDragDrop(),则拖放操作根本不会经过任何窗口过程,因为 OLE 拖放不使用窗口消息。

In a similar fashion to this question, I want to catch drag'n'drop events at a higher level in certain circumstances, before individual drop-handlers are invoked. But That question's answers suggest this isn't really possible?

这只能通过 DragAcceptFiles() 和子类化/ Hook 实现。

关于winapi - 对话框可以拦截传递给其控件的拖放消息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30737139/

相关文章:

c++ - 将工程应用程序从独立移动到内部 CAD

c++ - 获取正确的案例工作目录?

c++ - 是否需要删除渲染上下文并销毁设备上下文?

c++ - CreateCompatibleBitmap 在 Windows Mobile 6 上失败

java - 批处理文件显示无法找到或加载主类

xcode - Xcode中的iPad Storyboard无法拖动按钮

delphi - 从一个窗体拖动一个 TButton

c - 在 win32api 中直接读写硬盘,如 biosdisk 或 ms-dos 中的 absread

winapi - Win32 API - RegisterClassEx 错误

visual-c++ - MFC中OnPaint()函数的使用