Solved

How to trap Keystrokes like Ctrl-A-C

Posted on 1997-09-22
1
1,043 Views
Last Modified: 2013-11-19
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?


0
Comment
Question by:bola053097
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 120 total points
ID: 1306716
Use GetKeyboardState. This returns an array, indexed by the key and the value is determined by whether the key is down or not. Take a look at the online help for more information about GetKeyboardState().

0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 93
wait notify demo infinite loop 3 110
child constructor and parent constructor, overriding and overloading 6 84
Annoying "thing" blocks my view 4 100
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question