如何在wxWidget中关闭wxDialog?

问题描述 投票:0回答:1

我花了很多时间研究问题“如何关闭应用程序我通过wxDialog构建的内容我创建两个按钮,然后单击确定,然后退出,当我按Exit或在App的[X]信号上签名时,我会发出此错误

错误图像:enter image description here

  // The Queue of Event Table

    BEGIN_EVENT_TABLE(AutoPokemonDlg, wxDialog)
    EVT_BUTTON(wxID_OK, AutoPokemonDlg::OnOK)
    EVT_BUTTON(wxID_EXIT, AutoPokemonDlg::OnExit)
    EVT_CLOSE(AutoPokemonDlg::OnCloseWindow)
    END_EVENT_TABLE()


    // I create Event Handler

    void AutoPokemonDlg::OnExit(wxCommandEvent& WXUNUSED(event))
    {
        Close(true);
    }

    void AutoPokemonDlg::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
    {
        Destroy();
    }

    and main Window, i use wxDialog to inherit my subclass is AutoPikachuDlg
    ////AutoPokemonDlg.h
    class AutoPokemonDlg : public wxDialog
    {
    public:
        // Constructor
        AutoPokemonDlg(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size);
        ~AutoPokemonDlg();
        // Event handlers
        void OnOK(wxCommandEvent& event);
        void OnExit(wxCommandEvent& WXUNUSED(event));
        void OnCloseWindow(wxCloseEvent& event);

    protected:
    private:
        DECLARE_EVENT_TABLE()
    };

    //////AutoPokemonDlg.cpp
    AutoPokemonDlg::AutoPokemonDlg(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size)
        : wxDialog(parent, id, title, pos, size)
    {
    //...
    };
c++ wxwidgets
1个回答
0
投票

您没有显示如何创建和显示AutoPokemonDlg,但是如果您按照建议在堆栈上执行此操作,例如像这样:

© www.soinside.com 2019 - 2024. All rights reserved.