Main content: Introduce the messages commonly used in Windows programming
1.wm_lbuttondown produces a message with the left mouse button clicked
LParam:
low byte contains the x-coordinate value of the current cursor X = LoWord (LParam);
the high byte contains the y-coordinate value of the current cursor Y = HiWord (LParam);
WParam: Contains a set of integer values used to identify the pressed state of the mouse button
It can be used by switch-case.
give a couple of pressed states
Mk_lbutton Press the left mouse button
Mk_mbutton Press the middle mouse button
Mk_rbutton Press the right mouse button
Mk_shift hold down the SHIFT key
Mk_conyrol hold down the CTRL key
Example:
Case Wm_lbuttondown:
if (WParam & Mk_shift)//If SHIFT is also pressed
2. In addition, similar messages include:
wm_lbuttondown occurs when the left mouse button is pressed
Wm_lbuttonup When the left mouse button is released
Wm_rbuttondown when the right mouse button is pressed
Wm_rbuttonup when the right mouse button is released
WM_LBUTTONDBLCLK When you double-click the left mouse button
WM_RBUTTONDBLCLK When you double-click the right mouse button
Wm_mousemove when the mouse passes through the window's display area
Wm_mbuttondown occurs when the middle mouse button is pressed
Wm_mbuttonup when the middle mouse button is released
3.wm_keydown messages generated when a non-system key is pressed
<1> System Key: Refers to a combination of keys that implement system operation,
such as the combination of ALT and a function key to implement the system menu operation, etc.
non-system keys are keys that are not associated with ALT
notes:
The combination of ALT and other keys pressed together is called the "System Key",
when the window receives the system key, it is automatically interpreted as a system event,
or consult the Keyboard accelerator table to translate the system keys into the information specified by the accelerator table.
For example, a combination of ALT+F4 will force the window to close, and a combination of "ALT + letters" may pull down a menu.
Non-system key is the key when the ALT key is not pressed (such as a single button)
<2>wparam: Virtual code to identify pressed or released keys
LParam: Record the number of repetitions of keystrokes, scan codes, transfer codes, status of previous keys, and more
<3> similar to WM_KEYUP, messages generated when a non-system key is released
<4> virtual keys are identified at the beginning of vk_, such as Vk_shift,vk_lbutton, etc.
3. Other common messages
<1>wm_char messages generated when a non-system key is pressed
WParam is the same ASCII code as the key LParam and Wm_keydown
<2>wm_create: Message sent by the CreateWindow function
WParam not used
LParam contains a pointer to the CREATESTRUCT data structure
<3> wm_close: Message generated when closing a window
WPARAM and lparam are not used
WPARAM and lparam are not used
<5>wm_quit: Message sent by the PostQuitMessage function
WParam contains an exit code that identifies information about the program exiting the runtime
1-3-2 common messages for Windows applications