简体   繁体   English

在Internet Explorer_Server(IWebBrowser2)上拦截WM_COMMAND(从加速器发送)

[英]Intercept WM_COMMAND (sent from an accelerator) on Internet Explorer_Server (IWebBrowser2)

I need to intercept the Paste message that is being sent to my CHtmlView object. 我需要拦截发送到我的CHtmlView对象的粘贴消息。 According to Spy++, it's being sent as a WM_COMMAND message - but also according to Spy++, the message isn't being sent to the CHtmlView object, but rather to the Internet Explorer_Server (or IWebBrowser2) object that it wraps. 根据Spy ++,它是作为WM_COMMAND消息发送的 - 但是根据Spy ++,消息不会发送到CHtmlView对象,而是发送到它包装的Internet Explorer_Server(或IWebBrowser2)对象。 The WM_COMMAND message in question is not seen in any other parent objects (I've found this by observation and via Spy++). 在任何其他父对象中都看不到有问题的WM_COMMAND消息(我通过观察和通过Spy ++找到了这个消息)。

How do I intercept this (or even, say, a Select All) message? 如何拦截此消息(甚至是全部选择)消息? I've watched AfxCallWndProc for the correct WM_COMMAND message, and it doesn't show up there. 我已经看过AfxCallWndProc以获取正确的WM_COMMAND消息,并且它没有显示在那里。

To intercept a message (ex: WM_COMMAND) you need to subclass the window (in your case Internet Explorer_Server) by calling: 要拦截消息(例如:WM_COMMAND),您需要通过调用以下方式对窗口进行子类化(在您的案例中为Internet Explorer_Server):

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 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 the message. 之后,您自己的Windows程序首先获取控件,然后您可以决定如何处理该消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM