Focus window: The window that receives the keyboard event is called the window with the input focus. The window with the input focus is either the active window or the descendant window of the active window.
active window: the active window is usually very well identified. It is always the topmost window-in other words, its parent window handle is null.
System Message Queuing & Application Message Queuing
When a user presses and releases a key on the keyboard, the Windows and keyboard device drivers convert the hardware scan code to a formatted message. However, these messages are not immediately placed in the application message queue, but instead are stored in the system message queue by Wimdows. System Message Queuing is a separate message queue that is used by Windows to initially store messages that users enter from the keyboard and mouse. Windows removes the next message from the system message queue and puts it in the application message queue only after the Windows application has finished processing the previous user input message.
The messages that the application receives about keyboard events from Windows can be divided into two types: keystroke messages and character messages. For keystroke combinations that produce characters that can be displayed, Windows also sends a character message while sending a keystroke message. Some keys do not produce characters, such as the SHIFT key, the function key, the cursor movement key, and the special character keys (such as the INSERT and delete keys). For these keys, Windows only produces keystroke messages.
Character message
Wm_char,wm_syschar,wm_deadchar,wm_sysdeadchar
WParam is the key character, TCHAR (WParam) can get this character, do not distinguish this character is ASCII characters or Unicode characters, because the TCHAR data type has helped you to distinguish the good!
A button produces the following 4 messages: Wm_keydown,wm_char,wm_keyup,wm_deadchar 4 messages.
Keystroke messages
Usually the key presses the message and the key release message is paired. But if you press a key, it is considered that a continuous keystroke (auto-repeat) behavior occurs, and Windows sends a sequence of WM KEYDOWN (or Wmsyskeydown) messages to the window process. When this key is eventually released, Windows sends a wmkeyup (or wmsyskeyup) message to the window procedure. Like all queue messages, keystroke messages can be tracked in real time. You can get the relative time that the key is pressed or released by calling the Getmessagetime function.
System keystrokes
Indicates that this keystroke is more important to Windows than to Windows applications. The WM Syskeydown and WMSYSKEYUP messages are typically generated when the input and ALT keys are combined. The application typically ignores Wmsyskeyup and wmsyskeydown messages and delivers them to the DEFWINDOWPROC function to complete the default processing. Because Windows is concerned with all the ALT key feature logic, the application does not have to process these messages. If you have to deal with these messages, you still need to send these messages to the DEFWINDOWPROC function after processing, so that Windows does not affect its handling.
For all class four keystroke messages, wparam is a virtual key code that identifies which key was pressed or released, and Iparam contains some other data that is part of the keystroke. Most virtual key code names start with Vk_, which is defined in the Winuser Sun file. The lparam message parameter contains additional useful information to help understand keystrokes. The 32-bit LPARAM message is divided into 6 fields.
Windows Programming--keyboard messages