]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dialog.cpp
I think it's needed...
[wxWidgets.git] / src / msw / dialog.cpp
index dde02e52a8f4daa728c8842223ce669970ef88c2..874fecd0835ba3aecbaf3f755ce0c6f49d94a2df 100644 (file)
@@ -46,19 +46,17 @@ wxWindowList wxModalDialogs;
 wxWindowList wxModelessWindows;  // Frames and modeless dialogs
 extern wxList WXDLLEXPORT wxPendingDelete;
 
-#if !USE_SHARED_LIBRARY
-    IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
-
-    BEGIN_EVENT_TABLE(wxDialog, wxPanel)
-        EVT_SIZE(wxDialog::OnSize)
-        EVT_BUTTON(wxID_OK, wxDialog::OnOK)
-        EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
-        EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
-        EVT_CHAR_HOOK(wxDialog::OnCharHook)
-        EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
-        EVT_CLOSE(wxDialog::OnCloseWindow)
-    END_EVENT_TABLE()
-#endif
+IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
+
+BEGIN_EVENT_TABLE(wxDialog, wxPanel)
+    EVT_SIZE(wxDialog::OnSize)
+    EVT_BUTTON(wxID_OK, wxDialog::OnOK)
+    EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
+    EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+    EVT_CHAR_HOOK(wxDialog::OnCharHook)
+    EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+    EVT_CLOSE(wxDialog::OnCloseWindow)
+END_EVENT_TABLE()
 
 wxDialog::wxDialog()
 {
@@ -123,12 +121,12 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
     // resizeable or not (but a resizeable dialog always has caption -
     // otherwise it would look too strange)
     const wxChar *dlg;
-    if ( style & wxTHICK_FRAME )
-        dlg = _T("wxResizeableDialog");
+    if ( style & wxRESIZE_BORDER )
+        dlg = wxT("wxResizeableDialog");
     else if ( style & wxCAPTION )
-        dlg = _T("wxCaptionDialog");
+        dlg = wxT("wxCaptionDialog");
     else
-        dlg = _T("wxNoCaptionDialog");
+        dlg = wxT("wxNoCaptionDialog");
     MSWCreate(m_windowId, parent, NULL, this, NULL,
               x, y, width, height,
               0, // style is not used if we have dlg template
@@ -173,6 +171,9 @@ wxDialog::~wxDialog()
 
   Show(FALSE);
 
+  // VZ: this is bogus and breaks focus handling - it won't be returned to the
+  //     window which had it previosuly if we do this
+#if 0
   if (m_modalShowing)
   {
     // For some reason, wxWindows can activate another task altogether
@@ -184,6 +185,7 @@ wxDialog::~wxDialog()
     if (GetParent() && GetParent()->GetHWND())
       ::BringWindowToTop((HWND) GetParent()->GetHWND());
   }
+#endif // 0
 
   m_modalShowing = FALSE;
 
@@ -215,6 +217,9 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
         cancelEvent.SetEventObject( this );
         GetEventHandler()->ProcessEvent(cancelEvent);
 
+        // ensure that there is another message for this window so the
+        // ShowModal loop will exit and won't get stuck in GetMessage().
+        ::PostMessage(GetHwnd(), WM_NULL, 0, 0);
         return;
     }
   }
@@ -281,6 +286,11 @@ bool wxDialog::IsShown() const
   return m_isShown;
 }
 
+bool wxDialog::IsModal() const
+{
+    return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast
+}
+
 bool wxDialog::Show(bool show)
 {
   m_isShown = show;
@@ -469,7 +479,9 @@ bool wxDialog::Show(bool show)
         if (hWndParent)
           ::BringWindowToTop(hWndParent);
       }
-      ShowWindow((HWND) GetHWND(), SW_HIDE);
+
+      if ( m_hWnd )
+        ShowWindow((HWND) GetHWND(), SW_HIDE);
     }
   }
   return TRUE;