Page 1 of 1

How to closing wxAuiNotebook pages after ask?

Posted: Mon Sep 21, 2020 4:44 pm
by AndrzejB
I have wxAuiNotebook* notebook;
is bind: Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, &MyFrame::OnPageClose, this);
I do actions in OnPageClose, but how to prevent closing tab if user choose "No closing tab".

Re: How to closing wxAuiNotebook pages after ask?

Posted: Mon Sep 21, 2020 5:38 pm
by doublemax
From the "aui" sample:

Code: Select all

void MyFrame::OnNotebookPageClose(wxAuiNotebookEvent& evt)
{
    wxAuiNotebook* ctrl = (wxAuiNotebook*)evt.GetEventObject();
    if (ctrl->GetPage(evt.GetSelection())->IsKindOf(CLASSINFO(wxHtmlWindow)))
    {
        int res = wxMessageBox(wxT("Are you sure you want to close/hide this notebook page?"),
                       wxT("wxAUI"),
                       wxYES_NO,
                       this);
        if (res != wxYES)
            evt.Veto();
    }
}