菜单和工具栏随 wxTopLevelWindow::ShowFullScreen() 一起消失

Menu and toolbar disappear with wxTopLevelWindow::ShowFullScreen()

我尝试在全屏模式下自动显示我的应用程序。问题是我的工具栏和菜单栏随 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);
    
    }

ShowFullScreen 具有确定隐藏内容的标志。

wxFULLSCREEN_NOMENUBAR
wxFULLSCREEN_NOTOOLBAR
wxFULLSCREEN_NOSTATUSBAR
wxFULLSCREEN_NOBORDER
wxFULLSCREEN_NOCAPTION
wxFULLSCREEN_ALL (all of the above)

wxFULLSCREEN_ALL 是默认值。

因此,如果您想要使用工具栏和菜单栏。

this->ShowFullScreen(true, wxFULLSCREEN_NOSTATUSBAR || wxFULLSCREEN_NOBORDER || wxFULLSCREEN_NOCAPTION);

https://docs.wxwidgets.org/3.0/classwx_top_level_window.html#ab4089f1274bcb74e5f7763d1fb84ee28