Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to disable close button?

117 views
Skip to first unread message

Django Dunn

unread,
Jan 16, 2000, 3:00:00 AM1/16/00
to
I haven't been able to find how to disable the close button on the caption
bar but retain the min/max buttons. Can anyone help me?

Kind regards,

Django

Chris R. Timmons

unread,
Jan 16, 2000, 3:00:00 AM1/16/00
to
Django,

The code below assumes you give the user has another way to close the form
(like a TButton).

There is one button on the form (btnClose). If the user presses the X
(close) button on the caption bar, the FormCloseQuery event is fired, and
CanClose will be set to false. If the user presses the btnClose button,
ShouldFormClose will be set to true and the form will be allowed to close.

// Form level variable.
var
ShouldFormClose : boolean = false;

procedure TForm1.btnCloseClick(Sender: TObject);
begin
ShouldFormClose := true;
Close;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := ShouldFormClose;
end;

HTH,

Chris.
-----------
Django Dunn wrote in message ...

0 new messages