Interception WM_COMMAND (sent from the accelerator) to Internet Explorer_Server (IWebBrowser2)

I need to intercept the โ€œInsertโ€ message that is being sent to my CHtmlView object. According to Spy ++, it is sent as a WM_COMMAND message, but also according to Spy ++, the message is not sent to the CHtmlView object, but rather to the Internet Explorer_Server (or IWebBrowser2) object that it wraps. The WM_COMMAND message in question is not found in any other parent objects (I found this by observing and through Spy ++).

How to intercept this message (or even, say, select all)? I looked at AfxCallWndProc for the correct WM_COMMAND message and it does not appear there.

+4
source share
1 answer

To intercept a message (e.g. WM_COMMAND), you need to subclass this window (in your case Internet Explorer_Server) by calling:

BOOL SetWindowSubclass( _In_ HWND hWnd, _In_ SUBCLASSPROC pfnSubclass, _In_ UINT_PTR uIdSubclass, _In_ DWORD_PTR dwRefData ); 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb773183(v=vs.85).aspx#set_windowsubclass

After that, your own Windows procedure takes controls first, and you can decide what to do with this message.

+1
source

Source: https://habr.com/ru/post/1438769/


All Articles