Solved

Handling WM_KEYDOWN

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 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

22 Experts available now in Live!

Get 1:1 Help Now