我知道我这样的程序是不对的,不过我只想知道为什么会有这样的现象。
在一个窗体上放一个按钮,程序如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
Btn:TButton;
begin
Btn.Free
end;end.
结果是点击按钮后窗体不见了;没有任何错误信息但是如果这样:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Btn:TButton;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
Btn.Free
end;end.
结果是点击按钮后什么反映也没有;也没有任何错误信息
//不明白为什么
在一个窗体上放一个按钮,程序如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
var
Btn:TButton;
begin
Btn.Free
end;end.
结果是点击按钮后窗体不见了;没有任何错误信息但是如果这样:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Btn:TButton;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
Btn.Free
end;end.
结果是点击按钮后什么反映也没有;也没有任何错误信息
//不明白为什么
所以系统认为form,free吧
http://expert.csdn.net/Expert/topic/569/569053.xml?temp=.5480005
系统环境:D5+WIN2000
老问题去来了!
建议兄弟先去了解类与对象之间的关系,
这个问题可以说是DELPHI的BUG,
但是它也是你不正确使用类和对象的结果,
所以也不能说它一定是个BUG!
再问一句,在 “http://expert.csdn.net/Expert/topic/569/569053.xml?temp=.5480005” 中的EAX是指什么?
能简单讲一下吗?我这没有“类与对象之间的关系”方面的资料
DS, SS, SP, BP, and标志寄存器
这个在计算机原理学过的~ 不过忘的差不多了