unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
MyStr:string;
begin
InputQuery('输入字符','如果输入为空将退出程序',MyStr);
if MyStr<>'' then Action:=caNone;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
MyStr:string;
begin
InputQuery('输入字符','如果输入为空将退出程序',MyStr);
if MyStr<>'' then Action:=caNone;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure WMClose(var Message: TWMClose); message WM_CLOSE;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WMClose(var Message: TWMClose);
var
MyStr:string;
begin
InputQuery('输入字符','如果输入为空将退出程序',MyStr);
if MyStr='' then inherited;
end;end.
gasi(红衣主教) ,请明示!!!!!
procedure TForm1.WMClose(var Message: TWMClose);
var
MyStr:string;
begin
// InputQuery('输入字符','如果输入为空将退出程序',MyStr);
// if MyStr='' then inherited;
{ OnYourPro: 你的自定义过程,返回是否满足自定义的“离开(关闭form)”的按钮里条件 }
if not OnYourPro then ShowMessage('先等会儿!...')
else inherited;
end;
我已经给你回信了,去收信吧。
不要骂Kingron(戒网中……)是傻瓜啊,他说得没错。
你应该在OnCloseQuery中判断条件,然后给CanClose赋值。
在按钮的OnClick中只要调用Close;就行了。
我一直都是这么做的,你可以试试,加不加分无所谓。祝你好运。
根据你的条件设置一个全局变量bCanClose为true或者false,再调用form1.close;
form1的onclose事件
if bCanClose then
Action:=caFree
else
Action:=caNone;
代码自己写吧。