From: Vadim Zeitlin Date: Sun, 21 Dec 2008 01:33:15 +0000 (+0000) Subject: don't restore the focus manually after closing the dialog, default Windows behaviour... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/88a6739128bcb9b5b68f0c2e74170ef62663b3a7 don't restore the focus manually after closing the dialog, default Windows behaviour seems to work just fine now (see #10240) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h index c9da9e53d2..c53c8b7426 100644 --- a/include/wx/msw/dialog.h +++ b/include/wx/msw/dialog.h @@ -120,8 +120,6 @@ private: // gripper if we have one void OnWindowCreate(wxWindowCreateEvent& event); - - wxWindow* m_oldFocus; bool m_endModalCalled; // allow for closing within InitDialog #if wxUSE_TOOLBAR && defined(__POCKETPC__) diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 2190cbd8e8..7b4ad2baaa 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -145,7 +145,6 @@ wxDEFINE_TIED_SCOPED_PTR_TYPE(wxDialogModalData) void wxDialog::Init() { - m_oldFocus = (wxWindow *)NULL; m_isShown = false; m_modalData = NULL; m_endModalCalled = false; @@ -165,9 +164,6 @@ bool wxDialog::Create(wxWindow *parent, { SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); - // save focus before doing anything which can potentially change it - m_oldFocus = FindFocus(); - // All dialogs should really have this style style |= wxTAB_TRAVERSAL; @@ -294,45 +290,10 @@ int wxDialog::ShowModal() // into account if ( !m_endModalCalled ) { - // modal dialog needs a parent window, so try to find one - wxWindow *parent = GetParent(); - if ( !parent ) - { - parent = FindSuitableParent(); - } - - // remember where the focus was - wxWindow *oldFocus = m_oldFocus; - if ( !oldFocus ) - { - // VZ: do we really want to do this? - oldFocus = parent; - } - - // We have to remember the HWND because we need to check - // the HWND still exists (oldFocus can be garbage when the dialog - // exits, if it has been destroyed) - HWND hwndOldFocus = oldFocus ? GetHwndOf(oldFocus) : NULL; - - // enter and run the modal loop - { - wxDialogModalDataTiedPtr modalData(&m_modalData, - new wxDialogModalData(this)); - modalData->RunLoop(); - } - - - // and restore focus - // Note that this code MUST NOT access the dialog object's data - // in case the object has been deleted (which will be the case - // for a modal dialog that has been destroyed before calling EndModal). - if ( oldFocus && (oldFocus != this) && ::IsWindow(hwndOldFocus)) - { - // This is likely to prove that the object still exists - if (wxFindWinFromHandle((WXHWND) hwndOldFocus) == oldFocus) - oldFocus->SetFocus(); - } + wxDialogModalDataTiedPtr modalData(&m_modalData, + new wxDialogModalData(this)); + modalData->RunLoop(); } return GetReturnCode();