]> git.saurik.com Git - wxWidgets.git/commitdiff
don't call ::ShowWindow() if don't have HWND yet
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 Oct 2005 16:52:41 +0000 (16:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 9 Oct 2005 16:52:41 +0000 (16:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35859 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/window.cpp

index 0874381013c364b7b9d0335bad8af1ec2f16c4ba..04f6f307a40c78a44f0ddb496c76e33cc8115a18 100644 (file)
@@ -704,12 +704,23 @@ bool wxWindowMSW::Show(bool show)
         return false;
 
     HWND hWnd = GetHwnd();
-    int cshow = show ? SW_SHOW : SW_HIDE;
-    ::ShowWindow(hWnd, cshow);
 
-    if ( show && IsTopLevel() )
+    // we could be called before the underlying window is created (this is
+    // actually useful to prevent it from being initially shown), e.g.
+    //
+    //      wxFoo *foo = new wxFoo;
+    //      foo->Hide();
+    //      foo->Create(parent, ...);
+    //
+    // should work without errors
+    if ( hWnd )
     {
-        wxBringWindowToTop(hWnd);
+        ::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE);
+
+        if ( show && IsTopLevel() )
+        {
+            wxBringWindowToTop(hWnd);
+        }
     }
 
     return true;