Re: Please help: How to close a application when specific time?
From: Jase (jshelley_at_spamblock.enersol.com.au)
Date: 04/01/04
- Next message: Roger Dahl: "Re: Dialog vs DialogBar in .net"
- Previous message: Sahil: "Application REPAINT Issue"
- Maybe in reply to: Sahil: "Re: Please help: How to close a application when specific time?"
- Next in thread: Ajay Kalra: "Re: Please help: How to close a application when specific time?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Apr 2004 16:13:26 +1000
"AA" <anthony@jadeflex.com> wrote in message
news:exV3Re6FEHA.580@TK2MSFTNGP11.phx.gbl...
> Dear sir,
> I try to write a MFC application that will automatically close at
> specific time.
> I use a OnTimer Event to check the time. If current time is equal to "exit
> time", the application will close automatically.
> But how to trigger the operation of "quit application"?
>
> I try to PostMessage(WM_QUIT) in the OnTimer Event. The application can
> quit successfully, but it don't call the OnCloseDocument() and the
> destructor of the document. SO, it have memory leak. How to quit it
> gracefully?
>
> Thanks
>
> --
> Regards,
>
> Anthony Lam
>
BTW PostQuitMessage(<exit code>) is no different to PostMessage(WM_QUIT,
<exit code>, 0), so I would expect the same result. Try
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_APP_EXIT, 0); (fakes clicking
the exit button in the file menu).
Second thing is that you should use a waitable timer
(CreateWaitableTimer(...)), otherwise, if your computer is in hibernation,
it won't wake up to handle the timer, and so won't quit.
Jase
- Next message: Roger Dahl: "Re: Dialog vs DialogBar in .net"
- Previous message: Sahil: "Application REPAINT Issue"
- Maybe in reply to: Sahil: "Re: Please help: How to close a application when specific time?"
- Next in thread: Ajay Kalra: "Re: Please help: How to close a application when specific time?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|