-void wxDialog::DoShowModal()
-{
- wxWindow* pParent = GetParent();
- wxWindow* pOldFocus = m_pOldFocus;
- HWND hWndOldFocus = 0;
-
- wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
- wxCHECK_RET( IsModal(), _T("can't DoShowModal() modeless dialog") );
-
- wxModalDialogs.Append(this);
- if (pOldFocus)
- hWndOldFocus = (HWND)pOldFocus->GetHWND();
-
- //
- // Remember where the focus was
- //
- if (!pOldFocus)
- {
- pOldFocus = pParent;
- if (pParent)
- hWndOldFocus = GetHwndOf(pParent);
- }
-
- //
- // Disable all other app windows
- //
- wxASSERT_MSG(!m_pWindowDisabler, _T("disabling windows twice?"));
-
- //
- // Disables other app windows and window proc message processing
- // until WinDismissDlg called
- //
- ::WinProcessDlg((HWND)GetHwnd());
-
- //
- // Before entering the modal loop, reset the "is in OnIdle()" flag (see
- // comment in app.cpp)
- //
- extern bool gbInOnIdle;
- bool bWasInOnIdle = gbInOnIdle;
-
- gbInOnIdle = FALSE;
-
- //
- // Enter the modal loop
- //
- while ( IsModalShowing() )
- {
-#if wxUSE_THREADS
- wxMutexGuiLeaveOrEnter();
-#endif // wxUSE_THREADS
-
- while ( !wxTheApp->Pending() && wxTheApp->ProcessIdle() )
- ;
-
- // a message came or no more idle processing to do
- wxTheApp->DoMessage();
- }
- gbInOnIdle = bWasInOnIdle;
-
- //
- // Snd 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 (pOldFocus && (pOldFocus != this) && ::WinIsWindow(vHabmain, hWndOldFocus))
- {
- //
- // This is likely to prove that the object still exists
- //
- if (wxFindWinFromHandle((WXHWND) hWndOldFocus) == pOldFocus)
- pOldFocus->SetFocus();
- }
-} // end of wxDialog::DoShowModal