【问题标题】:Menu and toolbar disappear with wxTopLevelWindow::ShowFullScreen()wxTopLevelWindow::ShowFullScreen() 菜单和工具栏消失
【发布时间】: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);
    
    }

【问题讨论】:

    标签: c++ wxwidgets


    【解决方案1】:

    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

    【讨论】:

    • 是的,我已经检查过了,但问题是我想打开我的窗口,就像我点击右上角的按钮让我的窗口全屏显示一样。使用 shoFullScreen 窗口并非完全全屏。
    • 那将是边界。 this->ShowFullScreen(true, wxFULLSCREEN_NOSTATUSBAR || wxFULLSCREEN_NOCAPTION);
    • 只有 noborder 很好,但我认为 ShowFullScreen 最终不是我想要的。我希望能够在软件运行时调整窗口大小并单击全屏按钮或退出按钮,但我希​​望首先以全屏模式打开。我不知道是否清楚。使用 ShowFullScreen 窗口顶部的按钮消失
    • this->最大化(真);
    • 是的,非常感谢。我在 ShowFullScreen() 上走错了路。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 1970-01-01
    • 1970-01-01
    • 2017-02-27
    • 2018-02-22
    • 1970-01-01
    相关资源
    最近更新 更多