比如当点击关闭按钮后,程序执行最小化窗口
4 个解决方案
#1
OnCloseQuery
#2
是的,可要留好后路啊。
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Application.Minimize;
CanClose:=False;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Application.Minimize;
CanClose:=False;
end;
#3
哇,已经解决了,我来晚了
#4
Occurs when the form closes.
type
TCloseAction = (caNone, caHide, caFree, caMinimize);
TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object;
property OnClose: TCloseEvent;
Description
Use OnClose to perform special processing when the form closes. The OnClose event specifies which event handler to call when a form is about to close. The handler specified by OnClose might, for example, test to make sure all fields in a data-entry form have valid contents before allowing the form to close.
A form is closed by the Close method or when the user chooses Close from the form's system menu.
The TCloseEvent type points to a method that handles the closing of a form. The value of the Action parameter determines if the form actually closes. These are the possible values of Action:
Value Meaning
caNone The form is not allowed to close, so nothing happens.
caHide The form is not closed, but just hidden. Your application can still access a hidden form.
caFree The form is closed and all allocated memory for the form is freed.
caMinimize The form is minimized, rather than closed. This is the default action for MDI child forms.
If a form is an MDI child form, and its BorderIcons property is biMinimize, then the default Action is caMinimize. If a MDI child form does not have these settings, the default Action is caNone, meaning that nothing happens when the user attempts to close the form.
If a form is an SDI child form, Action defaults to caHide.
To close and form and free it in an OnClose event, set Action to caFree.
This example displays a message dialog box when the user attempts to close the form. If the user clicks the Yes button, the form closes; otherwise, the form only minimizes.
procedure TForm1.FormClose(Sender: TObject; var
Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
type
TCloseAction = (caNone, caHide, caFree, caMinimize);
TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object;
property OnClose: TCloseEvent;
Description
Use OnClose to perform special processing when the form closes. The OnClose event specifies which event handler to call when a form is about to close. The handler specified by OnClose might, for example, test to make sure all fields in a data-entry form have valid contents before allowing the form to close.
A form is closed by the Close method or when the user chooses Close from the form's system menu.
The TCloseEvent type points to a method that handles the closing of a form. The value of the Action parameter determines if the form actually closes. These are the possible values of Action:
Value Meaning
caNone The form is not allowed to close, so nothing happens.
caHide The form is not closed, but just hidden. Your application can still access a hidden form.
caFree The form is closed and all allocated memory for the form is freed.
caMinimize The form is minimized, rather than closed. This is the default action for MDI child forms.
If a form is an MDI child form, and its BorderIcons property is biMinimize, then the default Action is caMinimize. If a MDI child form does not have these settings, the default Action is caNone, meaning that nothing happens when the user attempts to close the form.
If a form is an SDI child form, Action defaults to caHide.
To close and form and free it in an OnClose event, set Action to caFree.
This example displays a message dialog box when the user attempts to close the form. If the user clicks the Yes button, the form closes; otherwise, the form only minimizes.
procedure TForm1.FormClose(Sender: TObject; var
Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
#1
OnCloseQuery
#2
是的,可要留好后路啊。
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Application.Minimize;
CanClose:=False;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Application.Minimize;
CanClose:=False;
end;
#3
哇,已经解决了,我来晚了
#4
Occurs when the form closes.
type
TCloseAction = (caNone, caHide, caFree, caMinimize);
TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object;
property OnClose: TCloseEvent;
Description
Use OnClose to perform special processing when the form closes. The OnClose event specifies which event handler to call when a form is about to close. The handler specified by OnClose might, for example, test to make sure all fields in a data-entry form have valid contents before allowing the form to close.
A form is closed by the Close method or when the user chooses Close from the form's system menu.
The TCloseEvent type points to a method that handles the closing of a form. The value of the Action parameter determines if the form actually closes. These are the possible values of Action:
Value Meaning
caNone The form is not allowed to close, so nothing happens.
caHide The form is not closed, but just hidden. Your application can still access a hidden form.
caFree The form is closed and all allocated memory for the form is freed.
caMinimize The form is minimized, rather than closed. This is the default action for MDI child forms.
If a form is an MDI child form, and its BorderIcons property is biMinimize, then the default Action is caMinimize. If a MDI child form does not have these settings, the default Action is caNone, meaning that nothing happens when the user attempts to close the form.
If a form is an SDI child form, Action defaults to caHide.
To close and form and free it in an OnClose event, set Action to caFree.
This example displays a message dialog box when the user attempts to close the form. If the user clicks the Yes button, the form closes; otherwise, the form only minimizes.
procedure TForm1.FormClose(Sender: TObject; var
Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;
type
TCloseAction = (caNone, caHide, caFree, caMinimize);
TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object;
property OnClose: TCloseEvent;
Description
Use OnClose to perform special processing when the form closes. The OnClose event specifies which event handler to call when a form is about to close. The handler specified by OnClose might, for example, test to make sure all fields in a data-entry form have valid contents before allowing the form to close.
A form is closed by the Close method or when the user chooses Close from the form's system menu.
The TCloseEvent type points to a method that handles the closing of a form. The value of the Action parameter determines if the form actually closes. These are the possible values of Action:
Value Meaning
caNone The form is not allowed to close, so nothing happens.
caHide The form is not closed, but just hidden. Your application can still access a hidden form.
caFree The form is closed and all allocated memory for the form is freed.
caMinimize The form is minimized, rather than closed. This is the default action for MDI child forms.
If a form is an MDI child form, and its BorderIcons property is biMinimize, then the default Action is caMinimize. If a MDI child form does not have these settings, the default Action is caNone, meaning that nothing happens when the user attempts to close the form.
If a form is an SDI child form, Action defaults to caHide.
To close and form and free it in an OnClose event, set Action to caFree.
This example displays a message dialog box when the user attempts to close the form. If the user clicks the Yes button, the form closes; otherwise, the form only minimizes.
procedure TForm1.FormClose(Sender: TObject; var
Action: TCloseAction);
begin
if MessageDlg('Close application ?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
Action := caFree
else
Action := caNone;
end;