Kirix Support Forums

[RESOLVED]Closing wxAuiNotebook page close wxAuiMDIChildFram

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

[RESOLVED]Closing wxAuiNotebook page close wxAuiMDIChildFram

Postby R.U.10 on Mon May 21, 2007 10:02 am

[EDIT]
To solve my problem I overloaded wxAuiNotebook to veto the event
EVT_AUINOTEBOOK_PAGE_CHANGED and call RemovePage() on event
EVT_AUINOTEBOOK_PAGE_CLOSE.

Here is the interesting code in cpp file:
Code: Select all
BEGIN_EVENT_TABLE(MyNotebook, wxAuiNotebook)
    EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, MyNotebook::OnPageChanged)
    EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, MyNotebook::OnPageClose)
END_EVENT_TABLE()

void MyNotebook::OnPageClose(wxAuiNotebookEvent& evt)
{
   RemovePage(evt.GetSelection());
   evt.Veto();
}

void MyNotebook::OnPageChanged(wxAuiNotebookEvent& evt)
{
   evt.Veto();
}


[/EDIT]


Hello,

I work on Windows XP / VS2005

My app derives from wxAuiMDIParentFrame which contains (through a wxAuiManager) 2 wxAuiMDIChildFrame which contains in its turn (through another wxAuiManager) 1 wxAuiNotebook (among others). The Notebook contain 8 pages.

Inheritance:
MyParent : public wxAuiMDIParentFrame
MyChild : public wxAuiMDIChildFrame
MyNotebook : public wxAuiNotebook

MyParent.wxAuiManager[]{ MyChild.wxAuiManager[]{ MyNotebook } }

My problem is that when I close the first page of MyNotebook, it close the first MyChild tab, idem for the second, etc.
Moreover, I can access in the first two pages of MyNotebook (Strangely I have two Childs...) but not in the others (the app crashes)!

In step by step debug mode I am taken in the file line 2501:
C:\wxWidgets-2.8.3\src\common\wincmn.cpp
---
wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
---
The event object incriminated is wxAuiTabCtrl.

Thank you in advance for your Precious help.
Last edited by R.U.10 on Mon May 28, 2007 6:50 am, edited 1 time in total.
R.U.10
Registered User
 
Posts: 30
Joined: Mon May 21, 2007 9:26 am

Postby R.U.10 on Mon May 28, 2007 5:08 am

Here is a very simple code if someone would like to study my problem:

Code: Select all
#include <wx/wx.h>
#include <wx/aui/aui.h>

class MyApp: public wxApp
{
public:
    bool OnInit();
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
   wxAuiMDIParentFrame *testParent = new wxAuiMDIParentFrame(NULL, wxID_ANY, _("testParent"));

   wxAuiMDIChildFrame *testChild1 = new wxAuiMDIChildFrame(testParent, wxID_ANY, _("testChild1"));
   wxAuiMDIChildFrame *testChild2 = new wxAuiMDIChildFrame(testParent, wxID_ANY, _("testChild2"));

   wxAuiNotebook *theNotebook1 = new wxAuiNotebook(testChild1);
   wxAuiNotebook *theNotebook2 = new wxAuiNotebook(testChild2);

   wxPanel *thePanel1 = new wxPanel(theNotebook1);
   wxPanel *thePanel2 = new wxPanel(theNotebook1);
   wxPanel *thePanel3 = new wxPanel(theNotebook1);
   wxPanel *thePanel4 = new wxPanel(theNotebook1);
   wxPanel *thePanel5 = new wxPanel(theNotebook2);
   wxPanel *thePanel6 = new wxPanel(theNotebook2);

   thePanel1->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));
   thePanel2->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));
   thePanel3->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));
   thePanel4->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));
   thePanel5->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));
   thePanel6->SetBackgroundColour(wxColour(100+rand()%156, 100+rand()%156, 100+rand()%156));

   theNotebook1->AddPage(thePanel1, _("Page1"));
   theNotebook1->AddPage(thePanel2, _("Page2"));
   theNotebook1->AddPage(thePanel3, _("Page3"));
   theNotebook1->AddPage(thePanel4, _("Page4"));
   theNotebook2->AddPage(thePanel5, _("Page5"));
   theNotebook2->AddPage(thePanel6, _("Page6"));

   wxBoxSizer *theSizer1 = new wxBoxSizer(wxVERTICAL);
   wxBoxSizer *theSizer2 = new wxBoxSizer(wxVERTICAL);
   theSizer1->Add(theNotebook1, 1, wxEXPAND, 0);
   theSizer2->Add(theNotebook2, 1, wxEXPAND, 0);
   testChild1->SetSizer(theSizer1);
   testChild2->SetSizer(theSizer2);

   testParent->GetNotebook()->SetSelection(0);
   testParent->Show();
   return true;
}

IMPLEMENT_WXWIN_MAIN_CONSOLE


Closing the first tab of one of the Notebooks close the first child tab, idem for the second, etc.
Accessing to the 3rd tab of the Notebooks cause a crash located in the file:
C:\wxWidgets-2.8.3\src\common\wincmn.cpp (line 2501)
---
wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
---
R.U.10
Registered User
 
Posts: 30
Joined: Mon May 21, 2007 9:26 am

Postby sickboy on Wed Jun 06, 2007 8:55 am

I had the same problem with wxAuiMDIParentFrame, wxAuiMDIChildFrame and wxAuiMDIClientWindow (which is derived from wxAuiNotebook).
Sometimes it crash when i close the last tab when it tries to find the focus and sometimes when i try to create a new "first tab".

I'm using wxMSW 2.8.4 and the solution is to add:
Code: Select all
tab_frame->m_tabs = NULL;

before
Code: Select all
delete tab_frame;

in
Code: Select all
wxAuiNotebook::RemoveEmptyTabFrames()
sickboy
Registered User
 
Posts: 7
Joined: Wed Jun 06, 2007 8:40 am

Re: [RESOLVED]Closing wxAuiNotebook page close wxAuiMDIChildFram

Postby Ben on Wed Jun 27, 2007 6:29 am

Hi,

I've fixed the problem in the wxWidgets svn tree, in both the 2.8 branch and the trunk. Thanks for the report.

Best,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Return to wxAUI Questions, Thoughts & Feedback