+ // if no extended style given, determine it ourselves
+ if ( exstyle == (WXDWORD)-1 )
+ {
+ exstyle = 0;
+ (void) MSWGetStyle(GetWindowStyle(), &exstyle);
+ }
+
+ // all controls should have this style
+ style |= WS_CHILD;
+
+ // create the control visible if it's currently shown for wxWidgets
+ if ( m_isShown )
+ {
+ style |= WS_VISIBLE;
+ }
+
+ // choose the position for the control: we have a problem with default size
+ // here as we can't calculate the best size before the control exists
+ // (DoGetBestSize() may need to use m_hWnd), so just choose the minimal
+ // possible but non 0 size because 0 window width/height result in problems
+ // elsewhere
+ int x = pos.x == wxDefaultCoord ? 0 : pos.x,
+ y = pos.y == wxDefaultCoord ? 0 : pos.y,
+ w = size.x == wxDefaultCoord ? 1 : size.x,
+ h = size.y == wxDefaultCoord ? 1 : size.y;
+
+ // ... and adjust it to account for a possible parent frames toolbar
+ AdjustForParentClientOrigin(x, y);
+
+ m_hWnd = (WXHWND)::CreateWindowEx
+ (
+ exstyle, // extended style
+ classname, // the kind of control to create
+ label, // the window name
+ style, // the window style
+ x, y, w, h, // the window position and size
+ GetHwndOf(GetParent()), // parent
+ (HMENU)GetId(), // child id
+ wxGetInstance(), // app instance
+ NULL // creation parameters
+ );
+
+ if ( !m_hWnd )
+ {
+#ifdef __WXDEBUG__
+ wxFAIL_MSG(wxString::Format
+ (
+ _T("CreateWindowEx(\"%s\", flags=%08x, ex=%08x) failed"),
+ classname, (unsigned int)style, (unsigned int)exstyle
+ ));
+#endif // __WXDEBUG__
+
+ return false;
+ }
+
+ // install wxWidgets window proc for this window
+ SubclassWin(m_hWnd);
+
+ // set up fonts and colours
+ InheritAttributes();
+ if ( !m_hasFont )
+ {
+#if wxUSE_LISTCTRL || wxUSE_TREECTRL
+ // if we set a font for {list,tree}ctrls and the font size is changed in
+ // the display properties then the font size for these controls doesn't
+ // automatically adjust when they receive WM_SETTINGCHANGE
+ if ( wxDynamicCastThis(wxListCtrl) || wxDynamicCastThis(wxTreeCtrl) )
+ {
+ // not sure if we need to explicitly set the font here for Win95/NT4
+ // but we definitely can't do it for any newer version
+ // see wxGetCCDefaultFont() in src/msw/settings.cpp for explanation
+ // of why this test works
+
+ // TODO: test Win95/NT4 to see if this is needed or breaks the
+ // font resizing as it does on newer versions
+ wxFont font = GetDefaultAttributes().font;
+ if ( font == wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) )
+ {
+ SetFont(font);
+ }
+ }
+ else
+#endif // wxUSE_LISTCTRL || wxUSE_TREECTRL
+ {
+ SetFont(GetDefaultAttributes().font);
+ }
+ }
+
+ // set the size now if no initial size specified
+ SetInitialSize(size);
+
+ return true;