|
-
August 31st, 1999, 03:54 AM
#1
How to close an application using a timer event!
I want to close my application using a timer event (the application should kill itself). The timer is initialised and works, so what code do I have to write in the timer event routine? I tried things like OnClose(), OnDestroy() but then I got always an error message if I run the application. What did I forgot?
Thanks and regards
Sascha
-
August 31st, 1999, 03:58 AM
#2
Re: How to close an application using a timer event!
Hi,
I think you should send a WM_CLOSE-Message with SendMessage.
Bye, Jörg
-
August 31st, 1999, 08:05 AM
#3
Re: How to close an application using a timer event!
Try this:
OnTimer(UINT nIDEvent)
{
m_counter++;
if (m_counter>=m_end)
{
KillTimer(1);
exit(1);
}
}
Add int m_counter to as a member variable and initialize it with zero in OnInitDialog() or OnInitInstance(). m_end is the amount of timer ticks before your app should exit. Start the timer by:
SetTimer(1,1000,NULL);
and m_end is the number of seconds before your app ends.
-
August 31st, 1999, 08:18 AM
#4
Re: How to close an application using a timer event!
AfxGetMainWnd()->SendMessage(WM_CLOSE, NULL, NULL)
Let me know if this helps you.
Best regards,
Faby
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|