Can a dialog intercept drag'n'drop messages passed to its controls?

301 views Asked by At

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?

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? How to disable drag/drop when a dialog box is open

1

There are 1 answers

3
Remy Lebeau On BEST ANSWER

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?

If the controls are using DragAcceptFiles(), WM_DROPFILES messages will go directly to the window procedures of the individual controls, not to the window procedure of the dialog. If you want to intercept the messages, you will have to subclass the individual controls using SetWindowLongPtr() or SetWindowSubClass(), or use a message hook from SetWindowsHookEx().

If the controls are using RegisterDragDrop() instead, drag&drop operations will not go through any window procedures at all, as OLE drag&drop does not use window messages.

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?

This would only be possible with DragAcceptFiles() and subclassing/hooking.