to post a new message or reply to an existing one. If you are not registered, please
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Aug 8, 2011 - 11:56 AM
I am using Prof-UIS 2.91.
If I create a keyboard hook using CExtHookSpy or SetWindowsHookEx, the keyboard hook works fine, unless a popup menu is active.
If a popup menu is active, and one of the popup menu accelerators is pressed, the keyboard hook does not receive any KEYDOWN/KEYUP messages.
For example, I can replicate this by modifying the "MDI" sample:
1) Set CMainFrame base class inherit from CExtHookSpy.
2) Call HookSpyRegister( __EHSEF_KEYBOARD | __EHSEF_PRE_TRANSLATION ) in CMainFrame constructor.
3) Add OnHookSpyKeyMsg function override with TRACE message or debug breakpoint.
4) Run and press ALT+F to active main menu FILE popup menu.
5) They keyboard hook will intercept the ALT and F keydown and keyup messages in OnHookSpyKeyMsg function.
6) Press X for popup menu "Exit" item (which has X accelerator).
7) They keyboard hook will *NOT* intercept the X keydown/keyup message.
I want to intercept the X keydown message regardless if a popup menu is active. How can I do this?
I have also tried with SetWindowsHookEx, same result.
Aug 9, 2011 - 8:20 AM
CExtPopupMenuWnd does not use the
CExtHookSpy mechanism. It uses
SetWindowsHookEx Win32 API directly and invokes each time before menu tree appears on the screen and immediately after menu disappears. That’s why menu keyboard hooks are more important and you do not receive hook invocations. But popup menu sends the
CExtPopupBaseWnd::g_nMsgTranslateKeyboardEvent registered message which allows you to handle keyboard events of menu tree. The
WPARAM parameter is pointer to the
CExtPopupBaseWnd::TranslateKeyboardEventData_t object describing keyboard event. If its
m_bMessageHandled flag is set to
true by your handler method, you intercepted menu keyboard event.