I’m trying to decipher CHtmlView’s behaviour when files are dragged into the client area, so I’ve created a new MFC app and commented out the CHtmlView line that navigates to MSDN on startup. In my main frame, I’ve overridden CWnd::OnDropFiles() with a function that shows a message box, to see when WM_DROPFILES is sent.
OnDropFiles() gets triggered on all except the first time you try to drag a file into the application. Uniquely, that first time appears to be interpreted by the application as a request to display the data in the file rather than a request to open the file. I’ve tried overriding OnDrop() from the view class, but it’s never called.
Why is the first time different? How can I catch all attempts to drag a file into my app?
This is part of the underlying
WebBrowsercontrol behaviour.CHtmlViewsetsRegisterAsDropTargettotrueby default, which means the control intercepts the drop operation and performs its own processing.If you want to inhibit it, call
SetRegisterAsDropTarget(FALSE)in yourOnInitialUpdateimplementation. All drop operations will then interact with the main window.