如果对话框将其某些控件注册为放置目标,则用于这些控件的拖放消息将通过对话框的消息处理传递,以便对话框可以注册消息处理程序以通知/拦截这些消息消息?
以与此问题类似的方式,我希望在某些情况下在调用各个拖放处理程序之前捕获更高级别的拖放事件。但这个问题的答案表明这实际上不可能? 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/