The Windows message to applications for shutdown is WM_close or
WM_ENDSESSION.
Hence I would interrogate for this message in the formclosequery proc of
your
program, and carry out the necessary actions according to the state of
WM_close.
Try the code out below and put a break on the wm_close line to see if the
message returns true (Im not sure)
move your cursor over both wm_xxxx on break to see the state of both
messages.
For example:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  // Ask user if shutdown should occur.
  if (wm_close or WM_ENDSESSION) and (MessageDlg('Are you sure?',
mtConfirmation, mbYesNoCancel, 0) = mrYes)
  then CanClose := true    // Allow Windows to shut down.
  else CanClose := false;  // Prevent Windows from shutting down.
end;



Regards,
Alistair+
>Does anyone know how to detect if windows is shutting down?
>
>I want to display a warning/confirmation message when the user shuts down a
>specific application, but not have this message displayed when windows
>itself is being shut down.
>
>Cheers,
>
>> .-->
>>
>> Wilfred Verkley
>> Software Developer
>> Software Development
>> Wang NZ Ltd
>> DDI 9-3087788
>> Fax 9-3064600
>> Email [EMAIL PROTECTED]
>>
>---------------------------------------------------------------------------
>    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                  Website: http://www.delphi.org.nz
>


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to