Re: Disable OnOK() automatic call in MFC application
On Wed, 18 Feb 2009 18:55:29 +0100, No_Name <no_mail@no_mail.com> wrote:
I'd like you to explain me why you find it a bad idea to put code on
the PreTranslateMessage function ?
1. It is called only for queued messages. This is usually unimportant,
because you would have to be sent new input through SendMessage for it to
be a factor.
2. It is typically called through WalkPreTranslateTree, so if a parent
window wants to handle a message for a specific child, it will need to vet
the HWND. Just something to be aware of.
3. You have to do your own message-cracking.
4. It ignores the message map mechanism, which avoids the giant switch
statements typical of SDK-style programming, is supported by the tools,
works for queued and sent messages, is always specific to a given window,
and provides message-cracking.
I thought it was the best place to
catch messages, and (in my case) managing specific keystrokes coming
from a selling terminal keyboard ...?
It can be the best place, but mainly it's useful when you want a parent
window to handle a small number of messages for its children in cases for
which the children can't (reasonably) do so.
--
Doug Harrison
Visual C++ MVP