Learning C + + unlike. NET, it is important to understand how Windows programs work inside, because most of what he involves is an operating system call, and. NET is, after all, an opera in the. netframework.
What exactly is the interrelationship between Windows applications, operating systems, and computer hardware, and the following diagram gives a good explanation.
The down arrow ① is the result of the application running judgment processing, output to the output of the device.
The UP Arrow ② is an input device, entered into the operating system.
The down arrow ③ represents the API, and we want to explain what the following APIs are. An API is an application interface that indicates that an application can notify the operating system to perform a specific action, such as the operating system's ability to control sound from a sound card, but it does not know when the sound should be made, and what sound the application needs to tell the operating system. This relationship is like having a robot capable of walking, but if people don't tell it which way to go, the robot will not walk on its own. Here the robot is the operating system, people are the application. To the programmer, it can be understood that the function library can be called, C + + programmers are the same use of the operating system. The API invoked in Java is the function library provided in the JDK, and. NET programmer is a library of functions provided by. NETFramework.
The UP arrow ④ indicates that the operating system can pass the input device changes to the application. If a user presses a keyboard on a program activity, the operating system immediately perceives the event and knows which key the user is pressing, and the operating system does not decide how to react to the event, but instead transmits the event to the application, where the application decides how to respond to the incident. Like a driver who drives to see a car in front of us, our nerve endings (equivalent to the operating system) immediately perceive the event and pass it on to our brains (the equivalent of the application), and our brains finally decide how to react to the incident, such as putting on the brakes, stopping, Or a heroic hit (it is a SB practice). Respond to events.
How does the operating system pass the perceived events to the application? This is done through message mechanisms (messages). The operating system wraps each event into a structured msg called a message for delivery to the application, see MSDN.
The MSG structure is defined as follows:
typedef struct TAGMSG {HWND hwnd; UINT message; WPARAM WPARAM; LPARAM LPARAM; DWORD time; Point pt; MSG; The process is a message response.
Actually, it's written here as a 3 year. NET Developer. I feel it here, C + + is so, the mechanism of. NET event response. It is not a message mechanism. Message mechanism, is a great leap in the process, but also this message mechanism, the. NET Programmer's control encapsulation too dead, but also create a large number of developers can only drag controls. I learned C + + or really have a kind of enlightened feeling. NET programmer, or more C + + Bar!