WXWindows's simplest Hello World program

xiaoxiao2021-03-06  17

We know that when using Win32 or MFC, the easiest Hello World program is used to use the message box to Hello World.

Below I will use wxWindows, and the source code is as follows:

/ / ===============================================================================================================================================================================

// filename xi.cpp

/ / ===============================================================================================================================================================================

#ifndef _xi_cpp

#define _xi_cpp

#include "wx / wx.h" // ==================== // main Application class.// ============ ========= Class Xiapp: public wxapp {public: // init esvirtual bool oninit ();

#ENDIFIMPLEMENT_APP (XIAPP)

/ / ================================================= bool Xiapp :: oninit ()

{WxString msg; msg.printf (_t ("Hello World! / N") _t ("Welcome TO% S"), wxversion_string);

WxMessageBox (MSG, _T ("Hello World Sample", wxok | wxicon_information, null; Return False;

Since the program needs to configure the settings, it is mainly included in the directory of the link library and header file, so beginners must see the installation I wrote.

Taken to XIAPP, it means the details.

The above IMPLEMENT_APP (XIAPP) is the entry of the program for the entry of the program to Entry Class.

XIapp :: OnIt () is BOOL return value, if the initialization is successful, return to TURE, the program is running; if it returns false, the initialization failed, the program ends.

On the top, after displaying a message box, I let it return false, the program is over, otherwise, because I didn't create the main frame window FrameWnd, the program will run in the background, but there is no way to interact with it, only task The manager ends it.

Screenshot below:

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

New Post(0)