【发布时间】:2019-07-27 16:09:23
【问题描述】:
我将 CodeBlocks 用作带有 WxWidgets 的 IDE,以便开发基于按钮操作的简单应用程序:用户可以单击不同的按钮以从系统中获取信息。 我想在单击按钮时打开一个新框架,但我不知道该怎么做,因为我还是个新手,我找不到任何关于这个主题的教程。 点击 Button1 时如何创建和启动新框架?
如果你不能帮助我,你至少能给我一些好的链接,我可以理解如何做到这一点,好吗? 点击 Button1 时如何创建和启动新框架?
感谢您的支持!
这是我的基本代码: isolaApp.cpp
#include "isolaApp.h"
//(*AppHeaders
#include "isolaMain.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(isolaApp);
bool isolaApp::OnInit()
{
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
isolaFrame* Frame = new isolaFrame(1);
Frame->Show();
SetTopWindow(Frame);
}
return wxsOK;
}
isolaMain.cpp
#include "isolaMain.h"
#include <wx/msgdlg.h>
//(*InternalHeaders(isolaFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(isolaFrame)
const long isolaFrame::ID_BUTTON1 = wxNewId();
const long isolaFrame::ID_BUTTON2 = wxNewId();
const long isolaFrame::ID_SASHWINDOW1 = wxNewId();
const long isolaFrame::idMenuQuit = wxNewId();
const long isolaFrame::idMenuAbout = wxNewId();
const long isolaFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(isolaFrame,wxFrame)
//(*EventTable(isolaFrame)
//*)
END_EVENT_TABLE()
isolaFrame::isolaFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(isolaFrame)
wxMenu* Menu1;
wxMenu* Menu2;
wxMenuBar* MenuBar1;
wxMenuItem* MenuItem1;
wxMenuItem* MenuItem2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
SashWindow1 = new wxSashWindow(this, ID_SASHWINDOW1, wxPoint(168,72), wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN, _T("ID_SASHWINDOW1"));
Button1 = new wxButton(SashWindow1, ID_BUTTON1, _("Label"), wxPoint(143,163), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
Button2 = new wxButton(SashWindow1, ID_BUTTON2, _("Label"), wxPoint(143,225), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
SashWindow1->SetSashVisible(wxSASH_TOP, true);
SashWindow1->SetSashVisible(wxSASH_BOTTOM, true);
SashWindow1->SetSashVisible(wxSASH_LEFT, true);
SashWindow1->SetSashVisible(wxSASH_RIGHT, true);
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&isolaFrame::OnButton1Click);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&isolaFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&isolaFrame::OnAbout);
//*)
}
isolaFrame::~isolaFrame()
{
//(*Destroy(isolaFrame)
//*)
}
void isolaFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void isolaFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void isolaFrame::OnButton1Click(wxCommandEvent& event)
{
// I want to show a new
}
【问题讨论】:
-
看起来您与wxW forum 相同的帖子正在产生您需要(以及更多)的答案。这里这个问题大概可以删了。
-
是的,我要关闭它
标签: dialog codeblocks wxwidgets