不好意思,上次写的有点仓促,发出去了也没再看一下
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;