I'll give an example to illustrate what I want to do:
Code:
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
TButton* Button1 = new TButton(Form1);
Button1->OnClick = func;
Form1->InsertControl(Button1);
TButton* Button2 = new TButton(Form1);
Button2->OnClick = func;
Form1->InsertControl(Button2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::func(TObject* Sender)
{
//What do I write here?
}
How could I implement func so that when the user clicks on Button1 or Button2, it changes the caption of the clicked button to "hello"? This seems to reduce to the problem of accessing the object whose address the Sender pointer holds. While the ClassName and ClassNameIs methods allow you to find out what class sends the OnClick message, I can't find any TObject methods that let you access the properties and methods of the clicked object. Can anybody help?
Thanks!