This is how I solved it.
HWND hwnd = NULL;
CWnd *cwnd, *cwnd1;
cwnd = AfxGetApp()->m_pMainWnd->GetLastActivePopup();
if(cwnd != 0)
hwnd = cwnd->m_hWnd;
else
hwnd = NULL;
while(hwnd != NULL && hwnd != AfxGetApp()->m_pMainWnd->m_hWnd)
{
cwnd1 = cwnd->GetParent();
cwnd->SendMessage(WM_CLOSE, NULL, NULL);
cwnd=cwnd1;
if(cwnd != 0)
hwnd = cwnd->m_hWnd;
else
hwnd = NULL;
}
Thomas Noone < XXXX@XXXXX.COM > schrieb in im Newsbeitrag:
XXXX@XXXXX.COM ...
> Hi!
>
> I need to add a time-out feature to an existing MFC-VC++-App.
> My only problem at this point is finding any open modal dialogs, prior to
> shutting down/logging off.
>
> Using OnTimer:
>
> if(AfxGetApp()->m_pMainWnd->GetActiveWindow() != NULL)
> hwnd = AfxGetApp()->m_pMainWnd->GetActiveWindow()->m_hWnd;
> else
> hwnd = NULL;
>
> if(hwnd != NULL && hwnd != AfxGetApp()->m_pMainWnd->m_hWnd)
> {
> ::SendMessage(hwnd, WM_CLOSE, NULL, NULL);
> SetTimer(2,100,NULL);
> }
>
> works fine, if my app is running in the foreground.
>
> Once it's in the background, I haven't yet found a way to get a handle.
>
> Important:
> I do not want to get into "bookkeeping" of open dialogs etc. and I don't
> know the names of the dialogs.
>
> Any ideas?
>
> Thanks,
>
> Thomas
>
>