diff --git a/include/wx/window.h b/include/wx/window.h index 42a300ef82..4fff9c3cd8 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -174,15 +174,6 @@ public: // Create() wxWindowBase() ; - // pseudo ctor (can't be virtual, called from ctor) - bool CreateBase(wxWindowBase *parent, - wxWindowID winid, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxPanelNameStr); - virtual ~wxWindowBase(); // deleting the window @@ -1421,6 +1412,24 @@ public: virtual bool CanApplyThemeBorder() const { return true; } protected: + // helper for the derived class Create() methods: the first overload, with + // validator parameter, should be used for child windows while the second + // one is used for top level ones + bool CreateBase(wxWindowBase *parent, + wxWindowID winid, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxPanelNameStr); + + bool CreateBase(wxWindowBase *parent, + wxWindowID winid, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name); + // event handling specific to wxWindow virtual bool TryBefore(wxEvent& event); virtual bool TryAfter(wxEvent& event); diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 1a03e224ef..30dc010510 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -215,7 +215,6 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), long style, - const wxValidator& wxVALIDATOR_PARAM(validator), const wxString& name) { // ids are limited to 16 bits under MSW so if you care about portability, @@ -243,6 +242,20 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent, SetName(name); SetParent(parent); + return true; +} + +bool wxWindowBase::CreateBase(wxWindowBase *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxValidator& wxVALIDATOR_PARAM(validator), + const wxString& name) +{ + if ( !CreateBase(parent, id, pos, size, style, name) ) + return false; + #if wxUSE_VALIDATORS SetValidator(validator); #endif // wxUSE_VALIDATORS diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 274bc888c9..3773984990 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -476,19 +476,15 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, long style, const wxString& name) { - bool ret wxDUMMY_INITIALIZE(false); - wxSize sizeReal = size; if ( !sizeReal.IsFullySpecified() ) { sizeReal.SetDefaults(GetDefaultSize()); } - m_windowStyle = style; - - SetName(name); - - m_windowId = id == wxID_ANY ? NewControlId() : id; + bool ret = CreateBase(parent, id, pos, sizeReal, style, name); + if ( !ret ) + return false; wxTopLevelWindows.Append(this);