【发布时间】:2021-07-09 08:30:31
【问题描述】:
我尝试全屏自动显示我的应用。问题是我的工具栏和菜单栏随着 wxTopLevelWindow::ShowFullScreen() 函数消失,无论我添加什么选项。有人知道如何处理吗?
下面是我的代码的一部分:
MyApp.cpp
#include "MyApp.h"
wxIMPLEMENT_APP(MyApp);
MyApp::MyApp()
{
}
MyApp::~MyApp()
{
}
bool MyApp::OnInit()
{
wxInitAllImageHandlers();
MainWindow* mainWindow = new MainWindow("My software");
mainWindow->Show();
return true;
}
MainWindow.h
class MainWindow : public wxFrame
{
public:
MainWindow(const wxString& title);
~MainWindow();
wxMenuBar* menuBar = nullptr;
wxMenu* fileMenu = nullptr;
wxMenu* toolsMenu = nullptr;
wxToolBar* toolbar = CreateToolBar();
wxDECLARE_EVENT_TABLE();
private:
wxImagePanel* m_renderWindow;
};
MainWindow.cpp
MainWindow::MainWindow(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxPoint(0,0), wxSize(800,600))
{
SetIcon(wxIcon("icon.ico", wxBITMAP_TYPE_ICO));
wxBitmap png_ClosedDevice(wxT("close.png"), wxBITMAP_TYPE_PNG);
menuBar = new wxMenuBar();
fileMenu = new wxMenu();
toolsMenu = new wxMenu();
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(toolsMenu, _T("&Tools"));
SetMenuBar(menuBar);
this->SetBackgroundColour(*wxWHITE);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
m_renderWindow = new wxImagePanel(this, wxT("Image.png"), wxBITMAP_TYPE_PNG);
sizer->Add(m_renderWindow, 1, wxSHAPED | wxALIGN_CENTER);
this->SetSizer(sizer);
this->Layout();
this->ShowFullScreen(true);
toolbar->AddTool(10001, _T("ClosedDevice"), png_ClosedDevice);
Layout();
this->GetToolBar()->EnableTool(10001, false);
}
【问题讨论】: