请教,这语句if sender=freshname是什么意思?

解决方案 »

  1.   

    这个事件是由freshname接受的,又如
    if sender=button1 //判断事件是不是button1的事件
      

  2.   

    Sender是一个对象,Delphi中每个事件都会返回的一个默认参数,是事件的发生者if sender=freshname应该是判断sender是否为某个已有控件,freshname应该为某个控件的名字。
      

  3.   

    判断两个对象是否是同一个对象,实际上是判断地址是否相等,如下判断也行
    if Longint(sender)=Longint(freshname) then
      

  4.   

    下面是Delphi帮助里面的解释,写得很清楚,你自己翻过来看吧
    Using the Sender parameter
    n an event handler, the Sender parameter indicates which component received the event and therefore called the handler. Sometimes it is useful to have several components share an event handler that behaves differently depending on which component calls it. You can do this by using the Sender parameter in an if...then...else statement. For example, the following code displays the title of the application in the caption of a dialog box only if the OnClick event was received by Button1.procedure TMainForm.Button1Click(Sender: TObject);
    begin
    if Sender = Button1 then
      AboutBox.Caption := 'About ' + Application.Title
    else 
      AboutBox.Caption := '';
    AboutBox.ShowModal;
    end;