Declare an identifier for your timer, i.e. in CMyDialog.hsomewhere:
static const UINT ID_MY_TIMER = 1000;
Create a timer in your function OnInitDialog:
SetTimer(ID_MY_TIMER, 10000, NULL);
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 IDOKwith IDCANCELdepending on what you return from DoModal.
source
share