Board index » cppbuilder » OnClose vs OnCloseQuery

OnClose vs OnCloseQuery


2005-05-09 04:29:43 AM
cppbuilder114
Hi,
What is the difference if I place my conditional exit code and/or
executing pending code in OnClose() contrary to OnCloseQuery()?
In other words I can prevent closing in:
OnClose() by Action=caNone
OnCloseQuery() by CanClose=false
What are the differences?
--
Best regards,
Vladimir Stefanovic
 
 

Re:OnClose vs OnCloseQuery

Vladimir Stefanovic wrote:
Quote
What is the difference if I place my conditional exit code and/or
executing pending code in OnClose() contrary to OnCloseQuery()?
In other words I can prevent closing in:
OnClose() by Action=caNone
OnCloseQuery() by CanClose=false
What are the differences?
Hi, Vladimir. Hope you are well.
OnClose is *not* called when, say, WinXP wants to shut down the computer.
OnCloseQuery *is* called in this situation. There may be other situations
where OnClose is not called. I reckon it's always safer to user the
OnCloseQuery event as this seems to catch *any* attempt to close the
application. HTH,
--
Mark Jacobs
www.dkcomputing.co.uk
 

Re:OnClose vs OnCloseQuery

Thanks a lot... To be honest, I never used OnCloseQuery
and I noticed that almost everyone uses it - so I asked...
--
Best regards,
Vladimir Stefanovic
"Mark Jacobs" <www.jacobsm.com/mjmsg.htm?mj@critical>wrote in
message news:427f5231$ XXXX@XXXXX.COM ...
Quote
Vladimir Stefanovic wrote:
>What is the difference if I place my conditional exit code and/or
>executing pending code in OnClose() contrary to OnCloseQuery()?
>In other words I can prevent closing in:
>OnClose() by Action=caNone
>OnCloseQuery() by CanClose=false
>What are the differences?

Hi, Vladimir. Hope you are well.

OnClose is *not* called when, say, WinXP wants to shut down the computer.
OnCloseQuery *is* called in this situation. There may be other situations
where OnClose is not called. I reckon it's always safer to user the
OnCloseQuery event as this seems to catch *any* attempt to close the
application. HTH,
--
Mark Jacobs
www.dkcomputing.co.uk
 

{smallsort}

Re:OnClose vs OnCloseQuery

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
Thanks a lot... To be honest, I never used OnCloseQuery
and I noticed that almost everyone uses it - so I asked...



--
Best regards,
Vladimir Stefanovic
"Mark Jacobs" <www.jacobsm.com/mjmsg.htm?mj@critical>wrote in
message news:427f5231$ XXXX@XXXXX.COM ...
>Vladimir Stefanovic wrote:
>>What is the difference if I place my conditional exit code and/or
>>executing pending code in OnClose() contrary to OnCloseQuery()?
>>In other words I can prevent closing in:
>>OnClose() by Action=caNone
>>OnCloseQuery() by CanClose=false
>>What are the differences?
>
>Hi, Vladimir. Hope you are well.
>
>OnClose is *not* called when, say, WinXP wants to shut down the computer.
>OnCloseQuery *is* called in this situation. There may be other situations
>where OnClose is not called. I reckon it's always safer to user the
>OnCloseQuery event as this seems to catch *any* attempt to close the
>application. HTH,
>--
As for the situation where Windows shuts down or the user logs off, you
should (i.e. this is what I always do) catch the WM_QUERYENDSESSION message.
This message is sent in either case. (Log off/shutdown)
If this message is sent, OnCloseQuery should set CanClose always to TRUE,
otherwise your computer will wait forever for the application to terminate,
and won't shut down or log you off.
Gr, Hans