- m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
- GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
- m_foregroundColour = *wxBLACK ;
-
- m_defaultForegroundColour = *wxBLACK ;
- m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
- GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
-
- m_tilingDirection = orientation;
- if (m_tilingDirection == wxHORIZONTAL)
- wxMessageBox("Sorry, wxToolBar95 under Windows 95 only supports vertical tiling.\nPass the number of rows.", "wxToolBar95 usage", wxOK);
- m_rowsOrColumns = RowsOrColumns;
- m_currentRowsOrColumns = 0;
- m_maxWidth = -1;
- m_maxHeight = -1;
-
- m_hBitmap = 0;
-
- m_defaultWidth = DEFAULTBITMAPX;
- m_defaultHeight = DEFAULTBITMAPY;
- SetName(name);
-
- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- m_windowStyle = style;
-
- SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-
- SetParent(parent);
-
- DWORD msflags = 0;
- if (style & wxBORDER)
- msflags |= WS_BORDER;
- msflags |= WS_CHILD | WS_VISIBLE;
-
- if (width <= 0)
- width = 100;
- if (height <= 0)
- height = 30;
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
-
- m_windowId = (id < 0 ? NewControlId() : id);
-
- // Create the toolbar control.
- HWND hWndToolbar = CreateWindowEx(0L, // No extended styles.
- TOOLBARCLASSNAME, // Class name for the toolbar.
- "", // No default text.
- WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // Styles and defaults.
- x, y, width, height, // Standard toolbar size and position.
- (HWND) parent->GetHWND(), // Parent window of the toolbar.
- (HMENU)m_windowId, // Toolbar ID.
- wxGetInstance(), // Current instance.
- NULL ); // No class data.
-
- // Toolbar-specific initialisation
- ::SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), (LPARAM)0);
-
- m_hWnd = (WXHWND) hWndToolbar;
- if (parent) parent->AddChild(this);
-
- SubclassWin((WXHWND) hWndToolbar);
-
- return TRUE;
+ wxASSERT_MSG( (style & wxTB_VERTICAL) == 0,
+ wxT("Sorry, wxToolBar95 under Windows 95 only "
+ "supports horizontal orientation.") );
+
+ // common initialisation
+ if ( !CreateControl(parent, id, pos, size, style, name) )
+ return FALSE;
+
+ // prepare flags
+ DWORD msflags = 0; // WS_VISIBLE | WS_CHILD always included
+ if (style & wxBORDER)
+ msflags |= WS_BORDER;
+ msflags |= TBSTYLE_TOOLTIPS;
+
+ if (style & wxTB_FLAT)
+ {
+ if (wxTheApp->GetComCtl32Version() > 400)
+ msflags |= TBSTYLE_FLAT;
+ }
+
+ // MSW-specific initialisation
+ if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) )
+ return FALSE;
+
+ // 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;
+ int width = size.x;
+ int height = size.y;
+
+ if (width <= 0)
+ width = 100;
+ if (height <= 0)
+ height = m_defaultHeight;
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ SetSize(x, y, width, height);
+
+ return TRUE;