return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
}
+wxWindow *wxDialog::FindSuitableParent() const
+{
+ // first try to use the currently active window
+ HWND hwndFg = ::GetForegroundWindow();
+ wxWindow *parent = hwndFg ? wxFindWinFromHandle((WXHWND)hwndFg)
+ : NULL;
+ if ( !parent )
+ {
+ // next try the main app window
+ parent = wxTheApp->GetTopWindow();
+ }
+
+ // finally, check if the parent we found is really suitable
+ if ( !parent || parent == (wxWindow *)this || !parent->IsShown() )
+ {
+ // don't use this one
+ parent = NULL;
+ }
+
+ return parent;
+}
+
void wxDialog::DoShowModal()
{
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
// modal dialog needs a parent window, so try to find one
if ( !GetParent() )
{
- wxWindow *parent = wxTheApp->GetTopWindow();
- if ( parent && parent != this && parent->IsShown() )
- {
- // use it
- m_parent = parent;
- }
+ m_parent = FindSuitableParent();
}
DoShowModal();
// dialog window proc
// ---------------------------------------------------------------------------
-BOOL CALLBACK wxRefreshChildProc(HWND hwnd, LPARAM WXUNUSED(lParam))
-{
- ::InvalidateRect(hwnd, NULL, FALSE /* don't erase bg */);
-
- // continue enumeration
- return TRUE;
-}
-
long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
long rc = 0;
processed = TRUE;
if ( !HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
{
- ::EnumChildWindows(GetHwnd(), wxRefreshChildProc, 0);
+ ::InvalidateRect(GetHwnd(), NULL, FALSE /* erase bg */);
}
break;