看下面的这一段,运行到第二次的时候,赋值给了button1?真奇怪,为什么?
implementation
var i:integer;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var myButton1:TButton;
myButton2:TButton;
begin
if i=0 then
begin
myButton1 := TButton.Create(form1);
myButton2 := TButton.Create(myButton1);
i:=i+1;
end;
mybutton2.Caption:='cmj';
Try
if i=0 then
myButton1.Free;
myButton2.Caption := 'olleh';//Click;
except
MessageBox(Handle,'错啦错啦,你指到哪里去了?','无效指针',mb_Ok);
end;
end;
initialization
i:=0;
end.