Board index » cppbuilder » Sender - Urgent! (the easiest question to answer)

Sender - Urgent! (the easiest question to answer)

You can use dynamic_cast for you:

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
        TButton *btn = dynamic_cast<TButton*>(Sender);
        if(btn)
            btn->Caption = "Something";
    }

Gambit

Quote
"LGB" <hyperdel...@uol.com.br> wrote in message news:3d20b979_2@dnews...
> in BCB:
> void __fastcall TForm1::Button1Click(TObject *Sender);
> {
>   /* Which code could I write here to do the same line I typed above? */
>   /* Please: the same line (testing the Sender before and changing its
> property later)
> }

 

Re:Sender - Urgent! (the easiest question to answer)


I guess my question is a super basic one, but I need to know:
When using Delphi, I can manipulate the Sender variable by testing its type:
i.e.:

in Delphi:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (Sender is TButton) then (Sender as TButton).Caption:= 'Something';
end;

in BCB:
void __fastcall TForm1::Button1Click(TObject *Sender);
{
  /* Which code could I write here to do the same line I typed above? */
  /* Please: the same line (testing the Sender before and changing its
property later)

Quote
}

Thank you very much.

Other Threads