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.
解决方案 »
- Delphi的dcp文件是怎么生成的?dcp文件有什么作用?
- 如何動態生成TTabSheet 然後把它放在Page_Contorl裡
- 祝片三生日快乐,没说地....
- 高手幫忙,為何會出現SQL錯誤?
- 能教小弟一点调试Hook程序的方法吗
- ◆◆◆如何在网吧中让其他任意一台win98电脑死机??
- 各位大侠救救急!!救人一命胜造七级浮屠
- 如何打开动态连接库?
- SQL SERVER中有MYSQL中LIMIT的那功能吗?
- 高手请进,如何运行内存映射文件?
- 在取数据的空当,我想显示一条叫大家等待的提示信息,等数据取回是关闭。请问如何写?
- 一个字段的值是1,2,3,4,我想让它显示为第一,第二,第三,第四。怎么办?谢谢!
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;
代码自己写吧。