C++ get virtual key-code from LPSTR

I have some code below to try and extract a virtual key-code from a Edit control...  It's not working out at all...

I need to save it to the Registry, and then load it back in =(

For instance, if I put 'Q' in the textbox, I get 337 as the number (WRONG WRONG WRONG =()

Thanks,

Jake
//Extract
						LPSTR sHotKey;
						GetWindowText(GetDlgItem(hwnd, IDC_HOTKEY), sHotKey, 2);
						short iHotKey=VkKeyScan(*sHotKey);
						RegWrite(regkey, "Hotkey", iHotKey);
//Populate
//Nothing so far, as I can't even extract it properly, but I would need to SetWindowText...

Open in new window

LVL 14
jake072Asked:
Who is Participating?
 
tulasisivaConnect With a Mentor Commented:
int GetKeyNameText( LONG lParam,   LPTSTR lpString,    int nSize );
UINT MapVirtualKeyEx(          UINT uCode,    UINT uMapType,    HKL dwhkl);

try to use this two methods for your requirement.
Check MSDN for indetailed details.
0
 
jake072Author Commented:
tulasisiva,

I am aware of the functions, however, I cannot figure out how to make them work.

I have a Edit control, IDC_HOTKEY, which is set to receive 1 upper-case character to interpret.  I need to store the scan code in the registry and then load the scan code from the registry to populate the edit control on load.

I have been working with this for a week now, and cannot figure it out.  Could you help me?

Jake
0
 
jake072Author Commented:
No one can give me an example of how to do this?  PLEASE!!

Jake
0
 
jake072Author Commented:
tulasisiva,

I finally figured out what I was doing wrong... I was extracting the LOBYTE of the returned short from VkKeyScan =)

Attached code...  iHotKey will store the VK code; thanks, should've read more =)

Jake
int iHotKey;
short vHotKey;
vHotKey = VkKeyScan(*sHotKey);
iHotKey = LOBYTE(vHotKey);

Open in new window

0
 
jake072Author Commented:
Thanks again, included below is the code implementation; don't forget to use LOBYTE like I did =) !!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.