]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dialog.cpp
More compilation fixes for mingw-w64.
[wxWidgets.git] / src / msw / dialog.cpp
index 64d7f61bc6c404f8708f98cef6e13f6350c54945..d89e8ede2c441173a7f25cd59a8475d50af5a440 100644 (file)
@@ -184,7 +184,7 @@ bool wxDialog::Create(wxWindow *parent,
     CreateToolBar();
 #endif
 
-    if( HasFlag(wxRESIZE_BORDER) )
+    if ( HasFlag(wxRESIZE_BORDER) )
         CreateGripper();
 
     return true;
@@ -256,13 +256,15 @@ bool wxDialog::Show(bool show)
 
     if ( show )
     {
-        // dialogs don't get WM_SIZE message after creation unlike most (all?)
-        // other windows and so could start their life non laid out correctly
-        // if we didn't call Layout() from here
+        // dialogs don't get WM_SIZE message from ::ShowWindow() for some
+        // reason so generate it ourselves for consistency with frames and
+        // dialogs in other ports
         //
         // NB: normally we should call it just the first time but doing it
         //     every time is simpler than keeping a flag
-        Layout();
+        const wxSize size = GetClientSize();
+        ::SendMessage(GetHwnd(), WM_SIZE,
+                      SIZE_RESTORED, MAKELPARAM(size.x, size.y));
     }
 
     return true;
@@ -349,7 +351,7 @@ void wxDialog::SetWindowStyleFlag(long style)
 {
     wxDialogBase::SetWindowStyleFlag(style);
 
-    if( HasFlag(wxRESIZE_BORDER) )
+    if ( HasFlag(wxRESIZE_BORDER) )
         CreateGripper();
     else
         DestroyGripper();
@@ -357,13 +359,15 @@ void wxDialog::SetWindowStyleFlag(long style)
 
 void wxDialog::CreateGripper()
 {
-    if( !m_hGripper )
+    if ( !m_hGripper )
     {
+        // just create it here, it will be positioned and shown later
         m_hGripper = (WXHWND)::CreateWindow
                                (
                                     wxT("SCROLLBAR"),
                                     wxT(""),
-                                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
+                                    WS_CHILD |
+                                    WS_CLIPSIBLINGS |
                                     SBS_SIZEGRIP |
                                     SBS_SIZEBOX |
                                     SBS_SIZEBOXBOTTOMRIGHTALIGN,
@@ -373,9 +377,6 @@ void wxDialog::CreateGripper()
                                     wxGetInstance(),
                                     NULL
                                );
-
-        // position the gripper correctly after creation
-        ResizeGripper();
     }
 }
 
@@ -392,6 +393,9 @@ void wxDialog::ShowGripper(bool show)
 {
     wxASSERT_MSG( m_hGripper, _T("shouldn't be called if we have no gripper") );
 
+    if ( show )
+        ResizeGripper();
+
     ::ShowWindow((HWND)m_hGripper, show ? SW_SHOW : SW_HIDE);
 }
 
@@ -501,10 +505,6 @@ WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPar
 
                     case SIZE_RESTORED:
                         ShowGripper(true);
-                        // fall through
-
-                    default:
-                        ResizeGripper();
                 }
             }