Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Handling WM_KEYDOWN

Posted on 1999-01-29
4
Medium Priority
?
602 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 150 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

926 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