MDI and toolbars

Igor Korot ikorot at earthlink.net
Thu Mar 6 22:02:48 PST 2008


Hi, ALL,
Here is my code for wxView::OnSize()

wxSize size = ((wxMDIParentFrame *) wxTheApp->GetTopWindow())->GetClientSize();
if( m_canvas && m_frame )
{
	m_frame->SetSize( 0, 0, size.GetWidth() - 2, size.GetHeight()- 2 );
	wxSize sizeFrame = m_frame->GetSize();
	m_canvas->SetSize( 0, 0, sizeFrame.GetWidth(), sizeFrame.GetHeight() );
}

Now this is the code I have for wxDocViewMDIParentFrame::OnSize()

for( wxWindowList::compatibility_iterator iter = GetChildren().GetFirst(); iter; iter = iter->GetNext() )
{
	wxWindow *current = iter->GetData();
	if( !foundChild )
	{
		child = dynamic_cast<wxDocMDIChildFrame*>( current );
		if( child )
			continue;
	}
	if( !foundTb )
	{
		tb = dynamic_cast<wxToolBar*>( current );
		if( tb && tb->GetName() == _T( "PainterBar1" ) )
			foundTb = true;
	}
}
int style = tb->GetWindowStyle();
if( style & wxTB_VERTICAL )
{
	tb->SetSize( 0, 0, wxDefaultCoord, size.y );
	offset = tb->GetSize().x;
	child->SetSize( offset, 0, size.x - offset, size.y );
}
if( style & wxTB_HORIZONTAL )
{
	tb->SetSize( 0, 0, size.x, wxDefaultCoord );
	offset = tb->GetSize().y;
         child->SetSize( 0, offset, size.x - 2, ( size.y - offset ) - 2 );
}

My question is: which message will come first and how to make sure that the toolbar and
the child window are both accessible?

With this code toolbar is painted with the grey background (transparent).

Thank you.




More information about the wx-users mailing list