Avoid querying wxToolBar size in wxMSW while it's being recreated
Recreating the toolbar tried to offset the new toolbar window being created by the size of the existing toolbar, when it was set up as the main frame toolbar. Luckily, this didn't work because getting the size of a wxWindow without a valid HWND failed, but it resulted in debug warning messages and was a wrong thing to do in the first place. Fix this by hiding the old toolbar before destroying it, this suffices for the parent frame not to use it for the client area calculations.
This commit is contained in:
@@ -475,6 +475,14 @@ void wxToolBar::Recreate()
|
||||
const wxPoint pos = GetPosition();
|
||||
const wxSize size = GetSize();
|
||||
|
||||
// Hide the toolbar before recreating it to ensure that wxFrame doesn't try
|
||||
// to account for its size, e.g. to offset the position of the new toolbar
|
||||
// being created by the size of this toolbar itself. This wouldn't work
|
||||
// anyhow, because we can't query for the size of a window without any
|
||||
// valid HWND, but would result in debug warning messages and is just a
|
||||
// wrong thing to do anyhow.
|
||||
Hide();
|
||||
|
||||
UnsubclassWin();
|
||||
|
||||
if ( !MSWCreateToolbar(pos, size) )
|
||||
@@ -485,6 +493,9 @@ void wxToolBar::Recreate()
|
||||
return;
|
||||
}
|
||||
|
||||
// Undo the effect of Hide() above.
|
||||
Show();
|
||||
|
||||
// reparent all our children under the new toolbar
|
||||
for ( wxWindowList::compatibility_iterator node = m_children.GetFirst();
|
||||
node;
|
||||
|
Reference in New Issue
Block a user