| View previous topic :: View next topic |
| Author |
Message |
Danid Guest
|
Posted: Wed Feb 15, 2006 12:03 pm Post subject: Get the Object name |
|
|
Hello,
I place a TImage (I name it img1) on a form. How can i get the name of the image by clicking on it?
img1OnClick(TObject *Sender)
{
String imageName = ...;
ShowMessage (imageName );
}
Thanks, |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Feb 15, 2006 12:03 pm Post subject: Re: Get the Object name |
|
|
Danid wrote:
| Quote: | I place a TImage (I name it img1) on a form. How can i get the name of the image by clicking on it?
, |
img1OnClick(TObject *Sender)
{
TImage *Image = dynamic_cast<TImage*>(Sender);
if ( Image )
ShowMessage ( Image->Name() );
}
Hans. |
|
| Back to top |
|
 |
HF Guest
|
Posted: Wed Feb 15, 2006 12:03 pm Post subject: Re: Get the Object name |
|
|
sorry,
i thought component name... |
|
| Back to top |
|
 |
HF Guest
|
Posted: Wed Feb 15, 2006 12:03 pm Post subject: Re: Get the Object name |
|
|
ShowMessage(img1->Name);
or generally
ShowMessage(dynamic_cast<TComponent*>(Sender)->Name);
Ο "Danid" <nospam (AT) email (DOT) com> έγραψε στο μήνυμα
news:43f31015$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hello,
I place a TImage (I name it img1) on a form. How can i get the name of the
image by clicking on it?
img1OnClick(TObject *Sender)
{
String imageName = ...;
ShowMessage (imageName );
}
Thanks, |
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Feb 15, 2006 8:03 pm Post subject: Re: Get the Object name |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | 'Name' is a property, not a fuction:
ShowMessage(Image->Name);
|
A property can be a function too. Look at all kinds of events.
typedef void __fastcall (__closure *OnClientConnectEvent)(TCustomWinSocket *Socket );
OnClientConnectEvent FOnClientConnect;
__property OnClientConnectEvent
OnClientConnect ={read=FOnClientConnect,write=FOnClientConnect};
Using OnClientConnect directly one would need a functioncall:
OnClientConnect(Socket);
But here it was Name yes. My mistake.
Hans. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Feb 15, 2006 8:03 pm Post subject: Re: Get the Object name |
|
|
"Hans Galema" <notused (AT) notused (DOT) nl> wrote in message
news:43f31505 (AT) newsgroups (DOT) borland.com...
| Quote: | TImage *Image = dynamic_cast<TImage*>(Sender);
|
If the OnClick handler is only assigned to TImage objects, and never caled
manually, then use static_cast instead:
TImage *Image = static_cast<TImage*>(Sender);
| Quote: | ShowMessage ( Image->Name() );
|
'Name' is a property, not a fuction:
ShowMessage(Image->Name);
Gambit |
|
| Back to top |
|
 |
|