moved OnActivate() logic from wxFrame to wxDialog -- this fixes infinite loop when handling WM_ACTIVATE in DefDlgProc in some crazy situations

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15816 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-06-13 00:04:22 +00:00
parent 7cc3cec9a7
commit 085ad68651
6 changed files with 104 additions and 76 deletions

View File

@@ -348,12 +348,12 @@ wxWindowMSW::~wxWindowMSW()
// VS: make sure there's no wxFrame with last focus set to us:
for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
{
wxFrame *frame = wxDynamicCast(win, wxFrame);
wxTopLevelWindow *frame = wxDynamicCast(win, wxTopLevelWindow);
if ( frame )
{
if ( frame->GetLastFocus() == this )
{
frame->SetLastFocus((wxWindow*)NULL);
frame->SetLastFocus(NULL);
}
break;
}
@@ -2083,15 +2083,27 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
// ::IsDialogMessage() can enter in an infinite loop when
// WS_EX_CONTROLPARENT is specified and the currently focused
// window is disabled or hidden, so don't call it in this case
bool canSafelyCallIsDlgMsg = TRUE;
HWND hwndFocus = ::GetFocus();
if ( !hwndFocus ||
::IsWindowEnabled(hwndFocus) && ::IsWindowVisible(hwndFocus) )
while ( hwndFocus )
{
if ( ::IsDialogMessage(GetHwnd(), msg) )
if ( !::IsWindowEnabled(hwndFocus) ||
!::IsWindowVisible(hwndFocus) )
{
// IsDialogMessage() did something...
return TRUE;
// it would enter an infinite loop if we do this!
canSafelyCallIsDlgMsg = FALSE;
break;
}
hwndFocus = ::GetParent(hwndFocus);
}
if ( canSafelyCallIsDlgMsg && ::IsDialogMessage(GetHwnd(), msg) )
{
// IsDialogMessage() did something...
return TRUE;
}
}
}