wxWidgets-HelloWorld

cpp 复制代码
#include "wx/wx.h"


class MyApp : public wxApp
{
public:
	bool OnInit() override;
};

wxIMPLEMENT_APP(MyApp);

class MyFrame : public wxFrame
{
public:
	MyFrame();

private:
	void OnHello(wxCommandEvent& event);
	void OnExit(wxCommandEvent& event);
	void OnAbout(wxCommandEvent& event);
};

enum
{
	ID_Hello = 1
};

bool MyApp::OnInit()
{
	MyFrame *frame = new MyFrame();
	frame->Show(true);
	return true;
}

MyFrame::MyFrame()
	: wxFrame(nullptr, wxID_ANY, "Hello World")
{
	wxMenu *menuFile = new wxMenu;
	menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
		"Help string shown in status bar for this menu item");
	menuFile->AppendSeparator();
	menuFile->Append(wxID_EXIT);

	wxMenu *menuHelp = new wxMenu;
	menuHelp->Append(wxID_ABOUT);

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append(menuFile, "&File");
	menuBar->Append(menuHelp, "&Help");

	SetMenuBar(menuBar);

	CreateStatusBar();
	SetStatusText(wxT("Welcome to wxWidgets! 你好啊"));

	//CreateStatusBar(2);
	//SetStatusText("Welcome to wxWidgets! 你好", 1);

	Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
	Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
	Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
}

void MyFrame::OnExit(wxCommandEvent& event)
{
	Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& event)
{
	wxMessageBox("This is a wxWidgets Hello World example",
		"About Hello World", wxOK | wxICON_INFORMATION);
}

void MyFrame::OnHello(wxCommandEvent& event)
{
	wxLogMessage("Hello world from wxWidgets!");
}
相关推荐
旖旎夜光2 小时前
多态(11)(下)
c++·学习
yangpipi-2 小时前
《C++并发编程实战》 第4章 并发操作的同步
开发语言·c++
Chance_to_win2 小时前
C++基础知识
c++
有趣的我3 小时前
C++ 多态介绍
开发语言·c++
WBluuue3 小时前
Codeforces 1068 Div2(ABCD)
c++·算法
阿沁QWQ4 小时前
C++的map和set
开发语言·c++
charlie1145141916 小时前
现代C++工程实践:简单的IniParser3——改进我们的split
开发语言·c++·笔记·学习
fish_xk6 小时前
c++的引用和类的初见
开发语言·c++
晨尘光7 小时前
【Windows 下FlatBuffers 编译.fbs文件并应用】
c++·windows
煤球王子7 小时前
学而时习之:C++中的文件处理2
c++