Three-layer mechanism
1. The top is the Windows kernel. The Windows kernel maintains a message queue, and the second-level control center obtains its own jurisdictional messages from this message queue, processes them, some messages are processed directly, and some are sent to the next Level form (Window) or control
2. The second level control center is typically the application object for each Windows application
3. The third-level control center is a Windows Forms object, and each form has a default form procedure that handles the various messages received
1 • Message Queuing. Windows can maintain a message queue for all applications. The application must obtain a message from the message queue and then assign it to a window. 2 • Message loops. Through this loop mechanism the application retrieves the message from the message queue, assigns it to the appropriate window, and proceeds to retrieve the next message from the message queue, then assigns it to the appropriate window, in turn. 3 · Window procedure. Each window has a window procedure to receive the message that is passed to the window, and its task is to get the message and then respond to it. A window procedure is a callback function; After a message is processed, it usually returns a value to Windows. Note that a callback function is a function in a program that is called by a Windows or external module.
Windows message processing mechanism