-1

I'm new to c++ and wondering what "WM_KEYDOWN" is? And how to use it.

Thank you.

strcat
  • 5,376
  • 1
  • 27
  • 31
Kevinkeegan
  • 57
  • 2
  • 7
  • 1
    This is far too broad. Google around, do some research, get a good book on Windows GUI programming in C++ and come back with any specific problems you have. – Bojangles Mar 20 '12 at 00:58
  • Take a look at [http://stackoverflow.com/a/2441480/884410](http://stackoverflow.com/a/2441480/884410) – Raj Ranjhan Mar 20 '12 at 01:00
  • This site worked for me to start learning the Win32 API: [winprog](http://www.winprog.org/tutorial) – chris Mar 20 '12 at 01:29
  • 5
    If you're new to C++ you should maybe try something easier than Win32 api ... – Dinaiz Mar 20 '12 at 01:31
  • 1
    I just saw that, you'll need a decent understanding of the language before you can begin to cope with it. – chris Mar 20 '12 at 01:33
  • Oh, and by the by, there's a tag for the API should you have future questions about it: [winapi] – chris Mar 20 '12 at 01:35
  • Things like this can easily be solved with a quick trip to google. You can search WM_KEYDOWN and MSDN would most likely be the first link. MSDN is a great resource to use for all things win32. – Aleks Mar 20 '12 at 08:50

2 Answers2

3

WM_KEYDOWN is defined in Microsoft Docs:

#define WM_KEYDOWN  0x0100

While I don't have a better explanation than Microsoft's, I'll post what the doc says:

Posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the Alt key is not pressed.

Simply put, it is a value returned by Windows in a program when a key on the keyboard is pressed (and when Alt isn't). The opposite is WM_KEYUP, which will be emitted when you release the key.

Pang
  • 9,564
  • 146
  • 81
  • 122
Halim Qarroum
  • 13,985
  • 4
  • 46
  • 71
1

A message flag produced by your window when your key is pressed. You can use it in the message handler function like

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

Then register it to your WNDCLASS

WNDCLASS ws;
ws.lpfnWndProc = WndProc; 

See http://msdn.microsoft.com/en-us/library/gg153546(v=VS.85).aspx for more information about how to dual with WM_KEYDOWN in WndProc.

Marjeay
  • 65
  • 1
  • 6