Window Programming _ Message Classification

Source: Internet
Author: User

Window application leverages Windows messages (message)
Exchange information with applications and systems.
The message is divided into:
Message number: Identified by a predefined message name
BYTE parameter (WParam): Additional information used to provide the message
Long-byte parameter (LParam): Additional information for providing a message
Note: Additional information is related to the value of the specific message number, which is represented by the struct MSG in win

Structure MSG
typedef struct TAGMSG
{HWND hwnd; window handle, NULL to retrieve all messages residing in message queue
UINT message; The message value, identified by the macro definition in the Windows.h header file
WPARAM WPARAM; Contains additional information about the message, different messages whose values differ
LPARAM LPARAM;
DWORD time; Specify when messages are sent to the queue
Point pt; Specifies the position of the screen cursor when the message is sent, and the data type of the pointer is also a struct
}msg;
struct POINT
typedef struct TAGPOINT
{LONG x;
LONG y;
} point;

Message classification: There are several system-defined message classifications in VC,
Different prefix symbols are often used to classify messages that are subordinate to message macro recognition messages,
The system-defined message macro prefixes are as follows:
BM Represents a Button control message
CB indicates combo box control message
DM indicates default push-button control message
EM means edit Control message
LB indicates list box control message
SBM represents scroll bar control messages
WM represents window messages
Common messages for Windows programming:
Window Management messages
Initializing messages
Input message
System messages
Clipboard messages
Control processing messages
Control notification messages
scroll bar notification message
Non-user area messages
MDI messages
DDE Message
Application-Customized Messages

Wm_lbuttonup: Release the left mouse button when the resulting;
Wm_rbuttondown: Generated when right mouse button is clicked;
Wm_rbuttonup: Occurs when the right mouse button is released;
WM_LBUTTONDBLCLK: Generated when double-click the left mouse button;
WM_RBUTTONDBLCLK: Generated when you double-click the right mouse button.


System Key: Refers to a combination of keys that implement system operation,
For example, the combination of ALT and a function key to implement system menu operation, etc.

Common Windows messages:
1. Wm_lbuttondown: Generate a message with the left mouse button clicked
Lparam-> low byte contains the X coordinate of the current cursor
The high byte contains the y-coordinate of the current cursor
WPARAM contains a set of values to identify the pressed state of the mouse button

2. Wm_keydown: Press a non-system key to generate the message,
WParam: Press the virtual key of the key to identify the key pressed or released
LParam: Records the number of repetitions of keystrokes, scan codes, transfer codes, status of previous keys, and other information.

3. WM_ CHAR: Message generated when a non-system key is pressed
WParam ASCII code for keys
LParam the same as the Wm_keydown

4. WM_CREATE: Message sent by the CreateWindow function
WParam: Not used
LParam: Contains a pointer to the CREATESTRUCT data structure

5. WM_CLOSE: Message generated when the window is closed
WPARAM and lparam are not used.

6. Wm_destroy: Message sent by the Destroywiodow function
WPARAM and lparam are not used.

7. Wm_quit: Messages emitted by the PostQuitMessage function, messages emitted when exiting the application
WParam: Includes exit code to identify information about the program exiting the runtime
LParam: Not used

8. WM_PAINT: Required window redraw is the resulting message
Conditions of production:
The user moves or displays, the user changes the window size, the program scrolls through the window with the scroll bar,
The drop-down menu closes and needs to be restored to the covered part,
Windows clears the dialog boxes and other objects and needs to recover the covered parts

Window Programming _ Message Classification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.