X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f78c70f34bc54ada79763b7e1eb1a863a61f542a..591cc82deb5bc6dd0af6047ecfa7ce7cf4f8d859:/src/msw/dialog.cpp diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index f65ece0b5d..c7baa0359c 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -145,10 +145,8 @@ wxDEFINE_TIED_SCOPED_PTR_TYPE(wxDialogModalData) void wxDialog::Init() { - m_oldFocus = (wxWindow *)NULL; m_isShown = false; m_modalData = NULL; - m_endModalCalled = false; #if wxUSE_TOOLBAR && defined(__POCKETPC__) m_dialogToolBar = NULL; #endif @@ -165,9 +163,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; @@ -285,54 +280,16 @@ int wxDialog::ShowModal() { wxASSERT_MSG( !IsModal(), _T("ShowModal() can't be called twice") ); - m_endModalCalled = false; - Show(); // EndModal may have been called from InitDialog handler (called from - // inside Show()), which would cause an infinite loop if we didn't take it - // into account - if ( !m_endModalCalled ) + // inside Show()) and hidden the dialog back again + if ( IsShown() ) { - // 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(); @@ -342,7 +299,6 @@ void wxDialog::EndModal(int retCode) { wxASSERT_MSG( IsModal(), _T("EndModal() called for non modal dialog") ); - m_endModalCalled = true; SetReturnCode(retCode); Hide(); @@ -395,7 +351,7 @@ void wxDialog::DestroyGripper() // we're not shown at all as in this case ResizeGripper() might not // have been called yet) wxASSERT_MSG( !IsShown() || - ::GetNextWindow((HWND)m_hGripper, GW_HWNDNEXT) == 0, + ::GetWindow((HWND)m_hGripper, GW_HWNDNEXT) == 0, _T("Bug in wxWidgets: gripper should be at the bottom of Z-order") ); ::DestroyWindow((HWND) m_hGripper); m_hGripper = 0;