Solved

Handling WM_KEYDOWN

Posted on 1999-01-29
4
575 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multi Table MS Access Query 5 75
Need example 5 113
T-SQL Debugging - Temp Object Content 2 54
.NET tools for adding thread safety to a web app? 3 31
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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