How to get text out a TCustomLabel

How can I get the text out a TCustomLabel

if Controls[i] is TCustomLabel then
  Text := TCustomLabel(Controls[i]).(Want to get the text);

Is their any way exept to use

if Controls[i] is TLabel then
  Text := TCustomLabel(Controls[i]).caption;
delproAsked:
Who is Participating?
 
RadlerConnect With a Mentor Commented:
Using the hierarchy, the property Caption is visible at TLabel, so
if Controls[i] is TLabel   then
      Text := TLabel((Controls[i]).Caption;
end;
How Formx.Controls[i] always is a TControl instace, is valid to do only:
var
      Txt : array[0..128] of char;
Controls[i].GetTextBuffer( Txt, 127 );

try use this with any Control to see the results.

0
 
simonetCommented:
The ".Caption" way is the correct way of doing it.

Yours,

Alex
0
 
simoraikovCommented:
Why you don't want to use ".caption"
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
rwilson032697Commented:
Well, if you are masochistic you can use the WM_GETTEXT API message to get the text from the edit control...

Cheers,

Raymond,

0
 
ptmcompCommented:
Hi guys
I think Radler is right.
Simonet: Sorry a TCustomLabel has no caption property.
rwilson: WM_GETTEXT works only for windows (TWincontrols). Since TCustomLabel is a TGraphicControl that uses the parent TWinControl to be drawn, WM_GETTEXT will not work to extract the caption from a TCustomLabel.

Regards, ptm.
0
 
delproAuthor Commented:
It is Controls[i].GetTextBuf( Txt, 127 ); and not
  Controls[i].GetTextBuffer( Txt, 127 );
0
All Courses

From novice to tech pro — start learning today.