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 » OnHookSpyPreTranslateMessage question Collapse All
Subject Author Date
tera tera Aug 18, 2009 - 6:52 PM


When there is a focus to a docking bar

class CMainFrame : public CMDIFrameWnd
				 , public CExtHookSpy

I want to do hook of key input in OnHookSpyPreTranslateMessage.

However, OnHookSpyPreTranslateMessage and CMainFrame-PreTranslateMessage are called each.


When there is a focus to a bar,I want you to call only OnHookSpyPreTranslateMessage.

tera tera Aug 19, 2009 - 7:38 PM

When there is a focus to a docking bar

When I want to transmit Del Key to only CEdit,

In OnHookSpyPreTranslateMessage, I do not return false

It is not transmitted a message.

And Del Key of MainFrame side reacts.

Is not there the good method?


Technical Support Aug 20, 2009 - 7:45 AM

The message hooking mechanism is not what you need:

CEdit * pEdit = . . .
pEdit->SendMessage( WM_KEYDOWN, VK_DELETE );

Technical Support Aug 19, 2009 - 2:29 PM

The application’s CWinThread::PreTranslateMessage() virtual method and the main frame’s CFrameWnd::PreTranslateMessage() virtual method are invoked by MFC before messages will be delivered to window procedures. The CExtHoolSpy::OnHookSpyPreTranslateMessage() virtual methods are invoked earlier than MFC’s message pre-translation virtual methods because the CExtHoolSpy-based mechanism is based on the thread wide windows hooks. If some OnHookSpyPreTranslateMessage() virtual method returns true, then all the other OnHookSpyPreTranslateMessage() methods and MFC message pre-translation methods are not invoked too. This means the OnHookSpyPreTranslateMessage() method works exactly in the same way like MFC’s PreTranslateMessage() methods do. If you want to hook keyboard messages in your OnHookSpyPreTranslateMessage() method and hide them from MFC and window procedures, then your OnHookSpyPreTranslateMessage() method should return true for the intercepted messages.