]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dialog.cpp
wxCaret MSW bug fixes
[wxWidgets.git] / src / msw / dialog.cpp
index f58e8d96935b5662e246b695e57faa1d1abb3247..d1979b9a4e3639b27b3df6a6ffd326176ba6df9b 100644 (file)
@@ -310,7 +310,13 @@ bool wxDialog::Show(bool show)
   {
     if (show)
     {
-      m_hwndOldFocus = (WXHWND)::GetFocus();
+      // find the top level window which had focus before - we will restore
+      // focus to it later
+      m_hwndOldFocus = 0;
+      for ( HWND hwnd = ::GetFocus(); hwnd; hwnd = ::GetParent(hwnd) )
+      {
+        m_hwndOldFocus = (WXHWND)hwnd;
+      }
 
       if (m_modalShowing)
       {
@@ -627,3 +633,27 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event)
   Refresh();
 #endif
 }
+
+// ---------------------------------------------------------------------------
+// dialog window proc
+// ---------------------------------------------------------------------------
+
+long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+{
+    long rc = 0;
+    bool processed = FALSE;
+
+    switch ( message )
+    {
+        case WM_CLOSE:
+            // if we can't close, tell the system that we processed the
+            // message - otherwise it would close us
+            processed = !Close();
+            break;
+    }
+
+    if ( !processed )
+        rc = wxWindow::MSWWindowProc(message, wParam, lParam);
+
+    return rc;
+}