]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
compilation fix for wxOSX_USE_EXPERIMENTAL_FONTDIALOG==0 (closes #10834)
[wxWidgets.git] / src / msw / toplevel.cpp
index 17392121160a0d1d9f3b05e74f7d948fd12fb69c..cafb0cd7103294edc935d37bd36b078a2a2d4069 100644 (file)
@@ -373,29 +373,10 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
     // no dialogs support under MicroWin yet
     return CreateFrame(title, pos, size);
 #else // !__WXMICROWIN__
-    wxWindow *parent = GetParent();
-
-    // for the dialogs without wxDIALOG_NO_PARENT style, use the top level
-    // app window as parent - this avoids creating modal dialogs without
-    // parent
-    if ( !parent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) )
-    {
-        parent = wxTheApp->GetTopWindow();
-
-        if ( parent )
-        {
-            // don't use transient windows as parents, this is dangerous as it
-            // can lead to a crash if the parent is destroyed before the child
-            //
-            // also don't use the window which is currently hidden as then the
-            // dialog would be hidden as well
-            if ( (parent->GetExtraStyle() & wxWS_EX_TRANSIENT) ||
-                    !parent->IsShown() )
-            {
-                parent = NULL;
-            }
-        }
-    }
+    // static cast is valid as we're only ever called for dialogs
+    wxWindow * const
+        parent = static_cast<wxDialog *>(this)->
+                    GetParentForModalDialog(GetParent());
 
     m_hWnd = (WXHWND)::CreateDialogIndirect
                        (
@@ -653,6 +634,11 @@ bool wxTopLevelWindowMSW::Show(bool show)
 
             m_maximizeOnShow = false;
         }
+        else if ( m_iconized )
+        {
+            // iconize and show
+            nShowCmd = SW_MINIMIZE;
+        }
         else // just show
         {
             // we shouldn't use SW_SHOW which also activates the window for
@@ -736,7 +722,17 @@ bool wxTopLevelWindowMSW::IsMaximized() const
 
 void wxTopLevelWindowMSW::Iconize(bool iconize)
 {
-    DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
+    if ( IsShown() )
+    {
+        // change the window state immediately
+        DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
+    }
+    else // hidden
+    {
+        // iconizing the window shouldn't show it so just remember that we need
+        // to become iconized when shown later
+        m_iconized = true;
+    }
 }
 
 bool wxTopLevelWindowMSW::IsIconized() const
@@ -744,6 +740,9 @@ bool wxTopLevelWindowMSW::IsIconized() const
 #ifdef __WXWINCE__
     return false;
 #else
+    if ( !IsShown() )
+        return m_iconized;
+
     // don't use m_iconized, it may be briefly out of sync with the real state
     // as it's only modified when we receive a WM_SIZE and we could be called
     // from an event handler from one of the messages we receive before it,
@@ -993,8 +992,12 @@ void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
         return;
     }
 
-    if ( !DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL) &&
-            !DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) )
+    bool anySet =
+        DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
+    if ( DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG) )
+        anySet = true;
+
+    if ( !anySet )
     {
         wxFAIL_MSG( "icon bundle doesn't contain any suitable icon" );
     }