How to closing wxAuiNotebook pages after ask?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
AndrzejB
Experienced Solver
Experienced Solver
Posts: 76
Joined: Sun Nov 29, 2015 12:46 pm

How to closing wxAuiNotebook pages after ask?

Post by AndrzejB » Mon Sep 21, 2020 4:44 pm

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".

User avatar
doublemax
Moderator
Moderator
Posts: 15159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to closing wxAuiNotebook pages after ask?

Post by doublemax » Mon Sep 21, 2020 5:38 pm

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();
    }
}
Use the source, Luke!

Post Reply