【发布时间】:2019-03-26 14:36:33
【问题描述】:
我一直在一起学习 wxWidgets 和 C++,这非常令人兴奋。我一直在使用我能找到的所有在线教程,并且已经购买并正在阅读这本书。我很清楚许多教程(和书)已经过时了,所以我学习的一部分是将示例带到当前的实践中。
例如,我已将 wxwidgets wiki 上的“您的第一个应用程序”教程转换为使用动态 Bind() 而不是事件表,并将对 wxEVT_COMMAND_MENU_SELECTED 的引用更新为更新和首选的 wxEVT_MENU:
MyFrame::MyFrame(const wxString &title) : wxFrame(nullptr, wxID_ANY, title) {
MainMenu = new wxMenuBar();
wxMenu *FileMenu = new wxMenu;
MainMenu->Append(FileMenu, _T("File"));
SetMenuBar(MainMenu);
CreateStatusBar(1);
FileMenu->Append(MENU_New, _T("&New"), _T("Create a new file"));
FileMenu->Append(MENU_Open, _T("&Open"), _T("Open an existing file"));
FileMenu->Append(MENU_Close, _T("&Close"), _T("Close the current document"));
FileMenu->Append(MENU_Save, _T("&Save"), _T("Save the current document"));
FileMenu->Append(MENU_SaveAs, _T("Save &As"), _T("Save current document with new name"));
FileMenu->Append(MENU_Quit, _T("&Quit"), _T("Quit the editor"));
Bind(wxEVT_MENU, &MyFrame::NewFile, this, MENU_New);
Bind(wxEVT_MENU, &MyFrame::OpenFile, this, MENU_Open);
Bind(wxEVT_MENU, &MyFrame::CloseFile, this, MENU_Close);
Bind(wxEVT_MENU, &MyFrame::SaveFile, this, MENU_Save);
Bind(wxEVT_MENU, &MyFrame::SaveAsFile, this, MENU_SaveAs);
Bind(wxEVT_MENU, &MyFrame::Quit, this, MENU_Quit);
MainEditBox = new wxTextCtrl(this, TEXT_Main, _T("Hi!\n"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_RICH | wxNO_BORDER, wxDefaultValidator, wxTextCtrlNameStr);
}
现在,作为一个学习练习,我有兴趣弄清楚如何绑定到“调整大小”事件。我想做的,只是为了咧嘴笑,是在调整大小时在其状态栏中显示当前帧的大小:类似于(300:200),但随着帧大小的调整而动态变化。但是我没有弄清楚如何绑定到这个事件。
谁能给我一两个诱人的提示,告诉我如何实现这一点?提前谢谢你。
【问题讨论】: