1. event-driven, packaged into messages, and placed in the message queue.
2. When applications require hardware to do things, they call the operating system API (function ).
3. The operating system sends the perceived events to the application for processing. The processing process is a message response.
4. How does the Operating System pass perceived events to applications? ---- Message implementation.
5. The operating system packs each event into a struct MSG (Message) to pass it to the application.
Function;
Typedef struct tagmsn {
Hwnd;
Uint message;
Wparam;
Lparam;
DWORD time;
Point pt;
} MSG;
Tip:
An event occurs when the user performs an action on the computer input device;
The operating system perceives the event and packs the MSG (Message) style of the struct defined in the event in advance, and then passes it to the application;
The application processes the received MSG (Message), calls the API of the operating system, and allows the operating system to drive the computer;
The operating system interacts with the user through the struct msg
Handle
The handle is the resource identifier.
Window, icon,
Macro
WM (Windows message)
Differentiate the usage of variables from the types of Variables
Message Queue
The operating system creates a message queue for each application;
A message queue is a buffer first, and an array of variable types. Each element in the message queue array is a message,
The operating system puts each generated message into the message queue in sequence;
The application always removes the first message, and the messages in the message queue are moved forward in sequence;
After the application obtains the message, it will know the user's operations and program changes;
The application processes the acquired message, that is, the message response, which is implemented by encoding, that is, the windows program.
In the main code area, you can write specific code for the received message to respond to the message;
Other windows APIs will be called when you write code;
Tip:
The operating system places events in the message queue through the message mechanism and waits for the application to obtain the events;
When an application obtains an event for processing (Message response), the user needs to write code for the event,
Call the operating system API to implement corresponding functions;
Tip:
Understand the message itself. Different messages represent user operations and program statuses;
Understanding the operating system API. For specific messages, the operating system must execute specific functions to respond to the message;