From 26fe8aa9954bc649201be1eedcad360313638bbb Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 16 Feb 2011 21:44:15 +0000 Subject: [PATCH] Check for double creation (patch #12434) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@66914 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index a0ecd5817b..42b1be1c71 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -3579,6 +3579,16 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass, WXDWORD style, WXDWORD extendedStyle) { + // check a common bug in the user code: if the window is created with a + // non-default ctor and Create() is called too, we'd create 2 HWND for a + // single wxWindow object and this results in all sorts of trouble, + // especially for wxTLWs + wxCHECK_MSG( !m_hWnd, true, wxT("window can't be recreated") ); + + // this can happen if this function is called using the return value of + // wxApp::GetRegisteredClassName() which failed + wxCHECK_MSG( wclass, false, wxT("failed to register window class?") ); + // choose the position/size for the new window int x, y, w, h; (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);