how to close or discard a MFC dialog box Automatically after 10 seconds.
+9
A:
Declare an ID for your timer, i.e. in your CMyDialog.h
somewhere:
static const UINT ID_MY_TIMER = 1000;
Create a timer in your OnInitDialog
function:
SetTimer(ID_MY_TIMER, 10000, NULL); // 10000ms = 10 secs
Add a handler for WM_TIMER
(the generated function will be called OnTimer
):
void CMyDialog::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == ID_MY_TIMER)
{
EndDialog(IDOK);
}
...
}
Replace IDOK
with IDCANCEL
depending on what you return result you want from DoModal.
Rob
2009-06-11 09:47:03