Re: PreTranslateMessage
Hi Dave,
Check for WM_CHAR first.
If it's one of those, then I've got an ASCII character. Handle it.
Then if it's a WM_KEYDOWN
Check to see if its an ASCII character.
If so just let it go to the base class, and I'll get it as WM_CHAR
eventually.
If not, handle it.
Dave
Thanks. I got it to work following your method although I'm not sure I
understand why it is working and if I'm doing things right.
Here is what I did:
I wanted to write a test and see if I can distinguish the VK_UP from regular
characters.
Here is the code:
if (pMsg->message == WM_CHAR)
{
// it is a char
return CStatic::PretranslateMessage(pMsg);
}
if (pMsg->messsage == WM_KEYDOWN)
{
// check and see if it is ASCII
if (pMsg->wParam >= 32 && pMsg->wParam <= 126 && pMsg->wParam != VK_UP)
{
// It is ASCII; Note: I noticed that VK_UP is defined as "38" and
somehow '&' in the ASCII table is also 38.
// I don't understand how it can distinguish between the "&" and
VK_UP. It probably finds out later that this 38
// refers to a VK_UP and not a char so it does not synthetise a
char, correct ?
// If I leave out the pMsg->wParam != VK_UP, then my control never
catches VK_UP.
CStatic::PreTranslateMessage(pMsg);
}
else
{
if (pMsg->wParam == VK_UP)
{
// User pressed the arrow up
}
return TRUE;
}
return CStatic::PretranslateMessage(pMsg);
Does it seem right? Thanks.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4376 (20090828) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com