不好意思,上次写的有点仓促,发出去了也没再看一下 var Form1: TForm1; temp:TObject; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin temp:=Sender; end; procedure TForm1.Button2Click(Sender: TObject); begin if temp=nil then ShowMessage('curr temp is nil') else if Temp is TButton then ShowMessage('curr temp is Button:'+(temp As TButton).Name) else if Temp is TForm then ShowMessage('curr temp is Form:'+(temp As TForm).Name); end; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin temp:=Sender; end;
temp定义为外部变量
temp:=TComcopment;
事件了
temp:=Sender;
temp定义为外部变量
temp:=TComcopment;
请问你上面这句是定义变量 ??类型是什么啊?能说具体点吗?
var
Form1: TForm1;
temp:TObject;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
temp:=Sender;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if temp=nil then
ShowMessage('curr temp is nil') else
if Temp is TButton then
ShowMessage('curr temp is Button:'+(temp As TButton).Name) else
if Temp is TForm then
ShowMessage('curr temp is Form:'+(temp As TForm).Name);
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
temp:=Sender;
end;