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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use the Sender ?

Status
Not open for further replies.

Spent

Programmer
Mar 20, 2003
100
BG
Can you tell me in the following code how to set the Sender
property?
void __fastcall TForm1::ImageAllClick(TObject *Sender)
{
// how to change the Sender->Tag;

Sender->Tag=3; // Does not works !
}

Thank you !
 
use
((SomeOfYourObjects*) Sender)->Tag. But first you should in some way ensure what the sender os a pointer to an instance of SomeOfYourObjects.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Thank you.But Can you give me an example ?
 
Look:
((SomeOfYourObjects*) Sender)->Tag = 3;

put the real class name instead of SomeOfYourObjects.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Thank you Ion.Its working now.
 
((SomeOfYourObjects*) Sender)->Tag = 3;

is the outside set of parentheses necessary or is this
just another way of doing it.

(SomeOfYourObjects*) Sender->Tag = 3;

tomcruz.net

 
Another set of brackets is needed because it needs to type-cast Sender and not Sender->Tag. Without outside parentheses you would probably see the compiler-error (or at least warning about converting int to pointer or something like that...)
 
I have been using this

TSpeedButton *S;
S = (TSpeedButton*) Sender;
S->Enabled = false;

But I can see where the extra brackets are needed in the other usage.

thanx

tomcruz.net
 
the style of good tone say what is better to use extra brackets. Syntactically and programatically there is correct to not use them, but it is a bad coding style.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top