NO MFC Programming 04 - About Simple Result Output Temp77 (Original) Keyword NO MFC, Win32, API, Output
I remember that we can use the PrintF to verify the output of the program. In Windows, the output should be used for MessageBox (), just, it only processes the string! What should I do with the specific value? In fact, the results you calculate can be treated with WSPrintf (), it is the close relative of Printf! The maximum feature of the WSPrintf function is that it does not output to the screen, which only generates the string to be used by MessageBox. Plus LSTRCAT (additional string) is more convenient, below is the usage in the source code: (Assuming you are very familiar with PrintF Usage) // File Name: WinMain.cpp // Specify the following sentence Description This program is independent of the MFC , Can speed up compilation speed #define win32_lean_and_mean // Say no to mfc !! #include char Temp [77] = ""; // Define an empty string char Result [250] = ""; // // name: WinMain () // ------ --------------------------- Int Winapi WinMain (Hinstance Hinstance, Hinstance Hprevinstance, LPSTR LPCMDLINE, INT NCMDSHOW) {long x = - 40, y = 25, z = 0; z = x * y; // z is the result of our output verification WSPrintf (result, "results: % ld / n ", z); // The most basic WSPRINTF usage, the first parameter is the target string // First display result MessageBox (Null, Result," Sample_code __copyright - `Sea Breeze", MB_OK | MB_TOPMOST) WSPrintf (Temp, "full-scale:% ld ×% ld =% ld", x, y, z); LSTRCAT (RESULT, TEMP); // This is used to add a string method // second Display result Messagebox (Null, Result, "Sample_code __copyright -` Sea Breeze ", MB_OK | MB_TOPMOST; EXITPROCESS (0); Return Null;} / / About WSPRINTF Detailed Us, please see MSD n A prompt, this method I used to view the value of a variable before it was used. But now it seems to be not recommended. Because the MessageBox function is actually a macro, it creates a window to display the information, and also create a message loop to extract the message. If you need to carefully study and process the news in each message queue, then you will be wrong! About the message queue I will explain it in detail later. Some people don't understand why #define win32_lean_and_mean. The answer is very simple, because I want to include the simply streamlined content, which is much more fast when this sentence is compiled.