- if (m_modalShowing && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE))
- // dfgg: NB MUST test m_modalShowing again as the message loop could have triggered
- // a Show(FALSE) in the mean time!!!
- // Without the test, we might delete the dialog before the end of modal showing.
- {
- while (wxTheApp->ProcessIdle() && m_modalShowing)
- {
- // Keep going until we decide we've done enough
- }
- }
- }
- // dfgg: now must specifically re-enable all other app windows that we disabled earlier
- node=disabledWindows.First();
- while(node) {
- wxWindow* win = (wxWindow*) node->Data();
- if (wxModalDialogs.Member(win) || wxModelessWindows.Member(win))
- {
- HWND hWnd = (HWND) win->GetHWND();
- if (::IsWindow(hWnd))
- ::EnableWindow(hWnd,TRUE);
- }
- node=node->Next();
- }
- }
- else // !show
- {
- ::SetFocus((HWND)m_hwndOldFocus);
-
- wxModalDialogs.DeleteObject(this);
-
- wxNode *last = wxModalDialogs.Last();
-
- // If there's still a modal dialog active, we
- // enable it, else we enable all modeless windows
- if (last)
- {
- wxDialog *box = (wxDialog *)last->Data();
- HWND hwnd = (HWND) box->GetHWND();
- if (box->m_winEnabled)
- EnableWindow(hwnd, TRUE);
- BringWindowToTop(hwnd);
- }
- else
- {
- wxNode *node = wxModelessWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- HWND hwnd = (HWND) win->GetHWND();
- // Only enable again if not user-disabled.
- if (win->IsUserEnabled())
- EnableWindow(hwnd, TRUE);
- node = node->Next();
- }
- }
- // Try to highlight the correct window (the parent)
- HWND hWndParent = 0;
- if (GetParent())
- {
- hWndParent = (HWND) GetParent()->GetHWND();
- if (hWndParent)
- ::BringWindowToTop(hWndParent);
- }
- ShowWindow((HWND) GetHWND(), SW_HIDE);
- m_modalShowing = FALSE;
- }
- }
- else // !modal
- {
- if (show)
- {
- ShowWindow((HWND) GetHWND(), SW_SHOW);
- BringWindowToTop((HWND) GetHWND());
- }