Link to home
Start Free TrialLog in
Avatar of bola053097
bola053097

asked on

How to trap Keystrokes like Ctrl-A-C

I'm trapping WM_KEYDOWN messages in PreTranslate Message and
want to figure out if the user is pressing more than one
Key in addition to the Ctrl Key. What is the best way to do
that? Presently, I have something like :

switch(pMsg->message)
{
 case WM_SYSKEYDOWN:
 case WM_KEYDOWN:
      if (pMsg->wParam >= 65 && pMsg->wParam <= 97) {
            if (GetKeyState(VK_SHIFT) || GetKeyState(VK_CAPITAL)) TRACE("GOT Uppercase %c\n",pMsg->wParam);
            if (GetKeyState(VK_CONTROL)) TRACE("GOT Ctrl %c\n",pMsg->wParam);
            if (GetKeyState(VK_MENU)) TRACE("Got Alt %c\n",pMsg->wParam);
      }
}


This is good for one Key, say Ctrl-A, How can I trap
something like say Ctrl-A-C.

Also, some characters like '[' & ']' have Virtual codes
which don't map to their ASCII equivalents. For e.g.
for ']' I get virtual code 221 in the WM_KEYDOWN message
and ASCII 93 in the WM_CHAR message. How can I perform
this conversion in the WM_KEYDOWN message?


ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial