Solved

How to trap Keystrokes like Ctrl-A-C

Posted on 1997-09-22
1
1,037 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now