Hi All,
I have an test MDI application (MFC app developed in VS2012) which create a CPropertySheet dialog (modeless) up on a file menu click. The propertysheet contains two CPropertyPages. In one property page, i am popping-up a Modal dialog, up on a button click in that page. And after the closing of propertysheet (after closing modal dialog), it got with an issue that my main application window (frame window) loses focus and it goes to back ground. And another application windows which was in back of my application, came as foreground window. The mentioned issue is only happening, if modal dialog is launched from properypage,
otherwise no issues.
Please note that, i created properysheet as follows:
pSheet->Create(AfxGetMainWnd(), WS_SYSMENU|WS_MINIMIZEBOX|WS_OVERLAPPED|WS_CAPTION|DS_MODALFRAME|WS_VISIBLE);
I found a work around to fix the the issue by handling WM_DESTROY in my class which is derived from CProperySheet as follows:
void CMyProperySheet::OnDestroy()
{
CPropertySheet::OnDestroy();
::SetForegroundWindow(AfxGetMainWnd()->GetSafeHwnd());
}
The work around fixed the issue of main application goes to background. I would like to know what causes the main application windows to lose focus and goes to the back ground. if you have any idea, please share.
Thanks,
Prasanth