?
Solved

How to trap Keystrokes like Ctrl-A-C

Posted on 1997-09-22
1
Medium Priority
?
1,051 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 240 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

800 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