NO MFC Programming 04 - About Simple Results Output

zhaozj2021-02-16  42

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 to explain that the program is independent of the MFC, can speed up the compilation speed #define win32_lean_and_mean // Say no to mfc !!

#include

CHAR TEMP [77] = ""; // Defines 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 we want to output verification

WSPrintf (result, "result is:% 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, "all-on:% ld ×% ld =% ld", x, y, z);

LSTRCAT (RESULT, TEMP); // This is the method of adding a string

// Second display result MessageBox (Null, Result, "Sample_code __copyright -` Sea Breeze ", MB_OK | MB_TOPMOST);

EXITPROCESS (0); return null;}

/ / For details on WSPRINTF, please see MSDN

A tip, this method I used to use the value of a variable before it was often used in debugging. 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.

However, your machine is above 800 megabytes that you can't see!

This tutorial is too simple, it is written to the entry. `Sea Breeze October 11, 2002 PM 2:28 -------------------------- Temp77 origin:

Life is in a hurry, but it is quite a temporary variable because I was born in 77 years, so I named TEMP77!

Currently like songs: Jay Chou - Back to the past

转载请注明原文地址:https://www.9cbs.com/read-24606.html

New Post(0)