Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 May : Question about WM_QUERYENDSESSION

www.cryer.info
Managed Newsgroup Archive

Question about WM_QUERYENDSESSION

Subject:Question about WM_QUERYENDSESSION
Posted by:"Michael Gasser" (michael_gass..@bluewin.ch)
Date:Fri, 26 May 2006 13:48:38

Question about WM_QUERYENDSESSION


Using Delphi 7, Pro


I have an application with many forms, some of them with its own event
handler FormCloseQuery (for event onclosequery); canclose not always true.


"Closing manually"


If I close the MAIN FORM "manually" then the application of course
terminates (as we all expect) even if in some Forms FormCloseQuery canclose
is set to false.


"Windows shut down"


If the windows system wants to shut down, then all the forms of my app get
the WM_QUERYENDSESSION message. If any of my forms with event handler
FormCloseQuery responds with canclose=false then application is NOT
terminated and therefore Windows not shut down.


*****************************************************************

My question: Do I really have to handle the message WM_QUERYENDSESSION in
all my forms (with FormCloseQuery) or is there a more elegant way to do it?

*****************************************************************


If I understand well the Delphi7 component ApplicationEvents does NOT
receive the message WM_QUERYENDSESSION;. the forms get it.


If I understand well, the top most form of my app (and unfortunately NOT the
main form) gets the WM_QUERYENDSESSION first.


Example: Two forms, Main form Form1 and a second form Form 2,
Form2.FormStyle:= fsStayOnTop.

event handler Form2.FormClosequery canclose not always true.


*****************************************************************

=> Is it always safe to react only to WM_QUERYENDSESSION in the top most
form (in this example Form2) of my app?
*****************************************************************
(.by setting a global var WindowShutDown to true and adjusting the
FormCloseQuery event handlers of all the forms? Or lazy way: to just set all
FormCloseQuery to NIL.. Bad bad I know. and only "recommended" if we really
are sure that a WM_ENDSESSION will follow.)


Thank you

Michael

Replies:

www.cryer.info
Managed Newsgroup Archive