Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » About an accelerator key question Collapse All
Subject Author Date
tera tera Apr 2, 2009 - 10:37 PM


About an accelerator key

When there is a focus in the following points,

Accelerator key information is not notified MainFrame side of.

Please teach a good method notified MainFrame side of.

Technical Support Apr 6, 2009 - 9:02 AM

Please ensure how you are initializing the CExtHookSpy interface. In order to receive CExtHookSpy::OnHookSpyKeyMsg() and CExtHookSpy::OnHookSpyPreTranslateMessage() virtual method invocations for keyboard messages, you should initialize a spy object with the __EHSEF_KEYBOARD flag in the dwEHSEF parameter of the CExtHookSpy::HookSpyRegister() method invocation. It’s not enough to create your class derived from the CExtHookSpy class. You should register your spy object using the CExtHookSpy::HookSpyRegister() method.

tera tera Apr 7, 2009 - 1:05 AM


It is troublesome to do public of Hook every one class.

In the following commands,

   m_hKeyboardHook =

I want to transmit an accelerator key to main Window.

If there is a good command, please teach it

Technical Support Apr 8, 2009 - 3:43 AM

You don’t need any keyboard hooks for that. The keyboard accelerators are not translated due to specific implementation of the CDialog::PreTranslateMessage() virtual function. You should implement your accelerator key pre-translation by overriding the PreTranslateMessage() virtual method in your dialog class.

tera tera Apr 8, 2009 - 4:25 AM


By the control units such as a dialog unit or the combo box , It is troublesome to incorporate Pretransmessage.

I want to handle all just to declare Hook.

Is it impossible?


Technical Support Apr 8, 2009 - 6:46 AM

Yes, this is possible. You should derive some of your classes from CExtHookSpy. If your class is also derived from any MFC/Prof-UIS class (CObject, CCmdTarget, CWnd . . .), then the MFC/Prof-UIS class must be the first in the list of parent classes (class CYourClass : public CObject, public CExtHookSpy { . . . };). Then you should invoke the HookSpyRegister( __EHSEF_KEYBOARD | __EHSEF_PRE_TRANSLATION ); code in your class constructor and the HookSpyUnregister( __EHSEF_KEYBOARD | __EHSEF_PRE_TRANSLATION ); code in your class destructor. If your class is CWnd-based and you want it to be a spy only when it subclasses really created and valid HWND handle, then you should invoke the HookSpyRegister( __EHSEF_KEYBOARD | __EHSEF_PRE_TRANSLATION ); code in the PreSubclassWindow() virtual method and the HookSpyUnregister( __EHSEF_KEYBOARD | __EHSEF_PRE_TRANSLATION ); code in the PostNcDestroy() virtual method (this is what the CExtShellTreeCtrl and CExtResizableDialog classes do). After that you can implement the CExtHookSpy::OnHookSpyPreTranslateMessage() virtual method.

Technical Support Apr 3, 2009 - 10:56 AM

You should check invocation routes for the PreTranslateMessage() and OnCmdMsg() virtual methods in your project.

tera tera Apr 6, 2009 - 5:03 AM


Cannot I watch a message in HookSpy?

 Cannot I watch a message in Hook?