- if (modal)
- {
- if (show)
- {
- m_hwndOldFocus = (WXHWND)::GetFocus();
-
- wxList DisabledWindows;
- if (m_modalShowing)
- {
- BringWindowToTop((HWND) GetHWND());
- return TRUE;
- }
-
- m_modalShowing = TRUE;
- wxNode *node = wxModalDialogs.First();
- while (node)
- {
- wxDialog *box = (wxDialog *)node->Data();
- if (box != this)
- ::EnableWindow((HWND) box->GetHWND(), FALSE);
- node = node->Next();
- }
- node = wxModelessWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (::IsWindowEnabled((HWND) win->GetHWND()))
- {
- ::EnableWindow((HWND) win->GetHWND(), FALSE);
- DisabledWindows.Append(win);
- }
- node = node->Next();
- }
-
- ShowWindow((HWND) GetHWND(), SW_SHOW);
- EnableWindow((HWND) GetHWND(), TRUE);
- BringWindowToTop((HWND) GetHWND());
-
- if (!wxModalDialogs.Member(this))
- wxModalDialogs.Append(this);
-
- MSG msg;
- // Must test whether this dialog still exists: we may not process
- // a message before the deletion.
- while (wxModalDialogs.Member(this) && m_modalShowing && GetMessage(&msg, NULL, 0, 0))
- {
- if (m_acceleratorTable.Ok() &&
- ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), &msg))
- {
- // Have processed the message
- }
- else if (!IsDialogMessage((HWND) GetHWND(), &msg))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- 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();
- HWND hWnd = (HWND) win->GetHWND();
- if (::IsWindow(hWnd) && (wxModalDialogs.Member(win) || wxModelessWindows.Member(win) ))
- ::EnableWindow(hWnd,TRUE);
- node=node->Next();
- }
- }
- else // !show