BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Get the Object name

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Danid
Guest





PostPosted: Wed Feb 15, 2006 12:03 pm    Post subject: Get the Object name Reply with 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





PostPosted: Wed Feb 15, 2006 12:03 pm    Post subject: Re: Get the Object name Reply with quote



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





PostPosted: Wed Feb 15, 2006 12:03 pm    Post subject: Re: Get the Object name Reply with quote



sorry,
i thought component name...
Back to top
HF
Guest





PostPosted: Wed Feb 15, 2006 12:03 pm    Post subject: Re: Get the Object name Reply with quote

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





PostPosted: Wed Feb 15, 2006 8:03 pm    Post subject: Re: Get the Object name Reply with quote

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





PostPosted: Wed Feb 15, 2006 8:03 pm    Post subject: Re: Get the Object name Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.