A thorough understanding of Windows message types and the occurrence time is exactlyProgramThe key to design. Now, with the advent and death of the window, I will describe the occurrence and transmission of messages, as well as the rise and end of applications. See figure 1-5 and figure 1-6.
Why is it so complicated to end a program? Because the operating system is different from the Application division, the two are in a cooperative relationship, so they must do their respective tasks and notify each other by message. If you do not follow this game rule, it may be troublesome. You can perform a small experiment to intercept wm_destroy in the window function, but do not call postquitmessage. When you select close in the System menu, the window disappears on the screen (because defwindowproc calls destroywindow to destroy the window and release the data structure ), however, the application itself is not over (because the message loop cannot end) and it is still stored in the memory.