How windows program runs with VC ++

Source: Internet
Author: User

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;

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.