Windows programming experience
//////////////////////////////////// / 小序: Hello, my name is Zhu Ben, "Bamboo" It is "stupid" mean, my girlfriend often calls me this, I am really stupid for a long time (嘿, don't let your girlfriend call you this!) I have learned this long time Windows program design. (In fact, it is not long), there is no idea, I always want to write it out to give you "Tao Guao" (Northeast, it is said), can improve my writing ability (because it is too inferior), I can deepen my own understanding, I can help you, you can help you (you don't have a special pressure), just say so much, enter the topic! ///////////// //////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ' (This is a nonsense, but don't read nonsense! Truth is often here) Have you ever thought, why is it based on a Windows operating system? Let's answer: Windows application needs to use the application interface "API" (said focus) that is opened by the Windows operating system.
The Windows program is actually in the non-logical use of these API functions. I mentioned the "non-logical" three words (this is my opinion), which is the essence of the Windows program, this is the WINDOWS program operation The way (may be serious). Non-logical means that the procedure is not performed according to the order in advance, and it is based on the different operations of the user or some of the other reasons. This way is called "Message Driver" simple to explain what is called message driver, that is, the application is always waiting (waiting for the word may not be appropriate, but it is good to understand), it is absolutely not waiting for who will give it Love (I love to open, please don't show!) It is waiting for the user or the system message (that is, the command), after receiving the message, it will pass the message via DispatchMessage (& MSG) to the window function (window function is The core of the application will handle the message to call the corresponding method to call the corresponding method in advance by the program comparison table written in advance. This completes the processing of a message, next to the next message. Do you have to ask that is not a restless run? Of course, I will use the program itself to explain this problem: // message loop, through which is constantly acquired. While (GetMessage (& MSG, NULL, 0, 0)) {// Message Make some conversion translateMessage (& MSG); // Put the message to window functions DispatchMessage (& MSG);} return msg.wparam; just like this: When you click on the small fork in the upper right corner of the window, when you click Exit button, Windows will automatically join a message "WM_DESTROY" in our message queue. At this point, the window program has this part: Switch (message) {// Other code .. ....... // case wm_destroy: postquitmessage (0); return 0; believe that the general friends will understand, its role is to receive WM_DESTROY, by calling postquitmessage (0) letting Windows in the message In the list, add another message "wm_quit". Returns 0 when the getMessage function caught when WM_QUIT, the rest returns to 0 values, understand it, this can withstate the message loop. This is the most basic part of the Windows program design, it can be said to be the core. I have said something, I think that I have to learn Windows programming not based on a certain part, but to grasp the overall situation, there must be an overall concept, have a total view of the Windows programming has a certain understanding of each part of each part. (This is not to take care of the global, you have to calm down your heart, or you will swallow.) This will not go to the magic (嘿)
Write this, wait for me to write again (still early, 嘿嘿), I hope I don't have a white fee, I hope to use it for you. 88. Bamboo.