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 小时前
137 ≤ Chrome 主密钥获取研究
c++·chrome·windows·网络安全·逆向分析
汉克老师8 小时前
GESP6级C++考试语法知识(四、图与树(四))
c++·贪心算法·优先队列·哈夫曼编码·哈夫曼树·gesp6级·gesp六级
子兮曰8 小时前
whisper.cpp 深度解析:从边缘设备到实时语音识别
前端·c++·后端
特种加菲猫9 小时前
二叉搜索树:数据世界的“快速寻路指南”
开发语言·c++
naturerun9 小时前
从数组中删除元素的算法
数据结构·c++·算法
特种加菲猫9 小时前
STL关联容器:Set/Multiset与Map/Multimap详解
开发语言·c++
Andy9 小时前
C++ list容器基本逻辑结构详解
c++·windows·list
想唱rap10 小时前
传输层协议TCP
linux·运维·服务器·网络·c++·tcp/ip
瑶池酒剑仙11 小时前
C++类和对象完全指南:从封装继承多态到内存布局的面向对象宝典(雨夜论道)
c语言·开发语言·c++·visual studio
潇湘散客11 小时前
CAX软件插件化设计实现牛刀小试
c++·算法·图形学·opengl