Solved

Handling WM_KEYDOWN

Posted on 1999-01-29
4
574 Views
Last Modified: 2013-12-03
Hi,

I need to communicate with the client everytime a key is pressed. I have handled the windows message:

NOTIFY_CODE_HANDLER(TVN_KEYDOWN, OnKeyDown)

everytime a key is pressed I do the following:

LRESULT CTreeView::OnKeyDown(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled)
{
LPNMTVKEYDOWN pKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pnmh);

// Get the virtual key code from the NMTVKEYDOWN structure.
WORD wVKey = pKeyDown->wVKey;

As this is only a code, how do I convert it into the actual key pressed.. (Are there any macros). I then have to fire an event to the GUI telling it what key was pressed..

I would appreciate any help....

Thanks

Emma

0
Comment
Question by:middlel
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 50 total points
ID: 1419450
I think you need the function

MapVirtualKey() or MapVirtualKeyEx()

hope that helps,

ZOPPO
0
 
LVL 86

Expert Comment

by:jkr
ID: 1419451
You don't need any macro for that, the virtual key codes are defined in winuser.h, and match the ASCII codes of all alphabetical characters...
If this is not what you want to know, could you specify your problem a bit more detailed? ;-)
0
 

Author Comment

by:middlel
ID: 1419452
The MapVirtualKey seems to return a different code - scan code/vitual key code... Which ever one you pass in, it returns the other.

What I need is the letter pressed... So if the user presses "T", it will give me the virtual key code "84". If possible, I need to know how you translate 84 into the letter "T". I would then fire an event to the VB application passing the letter T..

If the ascii characters are defined in winuser.h, how do I get hold of it from within my method???

Many Thanks

Emma

0
 
LVL 86

Expert Comment

by:jkr
ID: 1419453
To cite myself ;-)

the virtual key codes match the ASCII codes of all alphabetical characters...

There's no need for conversion, hence...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

861 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

23 Experts available now in Live!

Get 1:1 Help Now