你看这个行不行!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
SpeedButton1: TSpeedButton;
procedure Button1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
procedure DoClick(Sender : TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
DoClick(Sender);
end;
procedure TForm1.DoClick(Sender: TObject);
begin
if Sender is TControl then
ShowMessage(Sender.ClassName);
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
DoClick(Sender);
end;
end.