在TForm1下当然self是form1了,你可以用
showmessage(sender.ClassName);

解决方案 »

  1.   

    在TForm1下当然self是form1了,你可以用
    showmessage(sender.ClassName);
    正确
      

  2.   

    Self--意义:指本类,也就是Self被引用的类。比如若在类TMyClass内引用了Self,那么Self=TMyClass
    现在在TForm1中引用所以应该是form1
      

  3.   

    看button的源代码
    procedure TButton.Click;
    var
      Form: TCustomForm;
    begin
      Form := GetParentForm(Self);
      if Form <> nil then Form.ModalResult := ModalResult;
      inherited Click;
    end;
    这里的self才是tbutton
      

  4.   

    Sender--意义:指本对象。Sender在什么对象相关代码里,那么Sender就是什么。
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(self.ClassName);
    end;
    当点击button1时弹出的窗口显示:Tform1,为什么不是Tbutton?真不明白,因为我想此时的self应该是button。
    一般来说可以这样简单认为:Self是指"."前面的那个东东!上例:Self是指TForm1
      

  6.   

    to madyak(下岗的程序员) and ScoutKing(失眠夜) 
    想请教:self.name->form1
    self.classname->Tform1
      

  7.   

    上面的解释还是不明白,我试过showmessage(sender.ClassName);显示的是:Tbutton,没错。但此时我点击的是button,它属于Tbutton类,类名应该是Tbutton,这样理解怎么不对呢?
      

  8.   

    点击button触发button1click事件
    此事件属于tform1
    所以......