Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Handling WM_KEYDOWN

Posted on 1999-01-29
4
Medium Priority
?
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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