Thanks for all your help.
The simplest solution I found was just to trap WM_QueryEndSession message on
your form and set a flag.
ie
procedure TExampleForm.WMQueryEndSession(var Message: TWMQueryEndSession);
begin
fDisableCloseConfirm := true;
inherited;
end;
// CloseQuery gets called from the ancestor method
procedure TExampleForm.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
CanClose :=
fDisableCloseConfirm
or (messageDlg ('Are you sure you want to exit ' + application.title +
'? ', mtConfirmation, [mbYes, mbNo], 0) = mrYes);
// rest of closing code here
end;
Useful behaviour for monitoring applications that should always be running
in the background but can close automatically when shutting down the
machine.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz