vertical wxToolbar problems in MSW

Leslie Newell lesnewell at fmail.co.uk
Fri Mar 2 07:20:43 PST 2007


Hi,

I have found a problem with vertical wxToolbars under wxWidgets 2.8.0, 
msw. If Realize() is called more than once it displays incorrectly and 
the buttons don't work. You don't need to add a button between the two 
calls but it demonstrates why Realize() can get called more than once.


Here is a patch for the minimal sample to demonstrate the problem:

31,32d30
<    #include <wx/artprov.h>
<
177,189d174
<
<     wxBoxSizer * sizer = new wxBoxSizer(wxVERTICAL);
<    wxToolBar * bar = new 
wxToolBar(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxTB_FLAT | 
wxTB_NODIVIDER|wxTB_VERTICAL);
<    bar->AddTool(1,_("btn1"),wxArtProvider::GetBitmap(wxART_FILE_SAVE));
<    bar->AddTool(2,_("btn1"),wxArtProvider::GetBitmap(wxART_FILE_SAVE));
<    bar->AddTool(3,_("btn1"),wxArtProvider::GetBitmap(wxART_FILE_SAVE));
<    sizer->Add(bar,wxALIGN_LEFT);
<    SetSizer(sizer);
<    bar->Realize();
<    bar->AddTool(3,_("btn1"),wxArtProvider::GetBitmap(wxART_FILE_SAVE));
<    bar->Realize();
<     sizer->Fit(this);
<     sizer->SetSizeHints(this);


I did some searching and found an old patch to fix the problem. It looks 
like a fudge to me but it does work.

--- src/msw/tbar95.cpp.0    Mon May 29 23:57:03 2006
+++ src/msw/tbar95.cpp    Tue Dec 12 14:19:33 2006
 -1063,9
+1063,9
     }
     else if ( m_nButtons > 0 ) // vertical non empty
toolbar
     {
-        if ( m_maxRows == 0 )
         {
             // if not set yet, have one column
+            m_maxRows = 1;
             SetRows(m_nButtons);
         }
     }

Thanks,
Les




More information about the wx-users mailing list