diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index c5155d88ab..03ca8fa7a3 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -211,6 +211,9 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) toolBar->AddTool(wxID_NEW, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file"); currentX += width + 5; toolBar->AddTool(wxID_OPEN, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); + currentX += width + 5; + toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1"); + toolBar->AddSeparator(); wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO); @@ -223,11 +226,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) if ( !smallicons ) { - toolBar->AddSeparator(); currentX += width + 5; - toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1"); - currentX += width + 5; - toolBar->AddSeparator(); toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 2"); currentX += width + 5; toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Toggle/Untoggle help button"); @@ -249,7 +248,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons) toolBar->Realize(); // Can delete the bitmaps since they're reference counted - int i, max = smallicons ? 2 : WXSIZEOF(toolBarBitmaps); + int i, max = smallicons ? 3 : WXSIZEOF(toolBarBitmaps); for (i = 0; i < max; i++) delete toolBarBitmaps[i]; diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 0ddb230f4b..98eed8bbd5 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -96,6 +96,7 @@ wxToolBarTool::wxToolBarTool(wxControl *control) { m_toolStyle = wxTOOL_STYLE_CONTROL; m_control = control; + m_index = control->GetId(); } wxToolBarTool::~wxToolBarTool() diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index b20b58c966..6617cd587a 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -134,14 +134,6 @@ bool wxToolBar95::Create(wxWindow *parent, if ( !CreateControl(parent, id, pos, size, style, name) ) return FALSE; - // set up the colors and fonts -#if 0 - wxRGBToColour(m_backgroundColour, GetSysColor(COLOR_BTNFACE)); - m_foregroundColour = *wxBLACK; - - SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); -#endif - // prepare flags DWORD msflags = 0; // WS_VISIBLE | WS_CHILD always included if (style & wxBORDER) @@ -151,16 +143,22 @@ bool wxToolBar95::Create(wxWindow *parent, if (style & wxTB_FLAT) { if (wxTheApp->GetComCtl32Version() > 400) - msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT; + msflags |= TBSTYLE_FLAT; } // MSW-specific initialisation if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) ) return FALSE; - // Toolbar-specific initialisation + // toolbar-specific post initialisation ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); + // set up the colors and fonts + wxRGBToColour(m_backgroundColour, GetSysColor(COLOR_BTNFACE)); + m_foregroundColour = *wxBLACK; + + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + // position it int x = pos.x; int y = pos.y; @@ -423,7 +421,11 @@ bool wxToolBar95::CreateTools() // and position the control itself correctly vertically RECT r; - SendMessage(GetHwnd(), TB_GETRECT, 0, (LPARAM)(LPRECT)&r); + if ( !SendMessage(GetHwnd(), TB_GETRECT, + tool->m_index, (LPARAM)(LPRECT)&r) ) + { + wxLogLastError("TB_GETRECT"); + } int height = r.bottom - r.top; int diff = height - size.y;