Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with *Sender usage

Status
Not open for further replies.

jbpelletier

Programmer
Sep 8, 2001
232
CA
I have an array of TButton.. witch all TButton Click event are link to one same event (Button1Click). How to know witch button as been click in that event code.. i know there is something to do with the sender.. but it seems hard to get the correct syntax to use it.. i need something like :
(Sender as TButton)->Enabled=false;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
//This code to give Enabled = false to the clicked button
....
}


jb.
 
Greetinx!

Try this:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
(TButton *)Sender->Enabled=false;
....
}



Happy programming!))
 
I have tried your code pavlo and it dont realy work..
(TButton *)Sender->Enabled=false;

I still have an error :
'Enabled' is not a member of 'System::TObject'.
 
I have tried your code pavlo and it dont realy work..
(TButton *)Sender->Enabled=false;

I still have an error :
'Enabled' is not a member of 'System::TObject'.

Any other idea?

Jb
 
Finaly i Got it...

Correct syntax is : ((TButton *)Sender)->Enabled=false;

tanx

jb

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top