Home > Windows API > Get key names as a string!

Get key names as a string!

Well how do you get key names, for eg: when you type “A” you should get a string like “A ” or when you press page down you get a string like “Page Down”!

It’s easy, there is a windows API for this purpose called GetKeyNameText.

LRESULT CMyDlg::WindowProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch( Message )
   {
   case WM_KEYDOWN:
      TCHAR szKeyname[MAX_PATH] = { 0 };
      GetKeyNameText( lParam, szKeyname, MAX_PATH );
      MessageBox( szKeyname );
      break;
   }
   return CDialog::WindowProc(Message, wParam, lParam);
}// End WindowProc
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: