Link to home
Start Free TrialLog in
Avatar of delpro
delpro

asked on

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;
Avatar of simonet
simonet
Flag of Brazil image

The ".Caption" way is the correct way of doing it.

Yours,

Alex
Avatar of simoraikov
simoraikov

Why you don't want to use ".caption"
Well, if you are masochistic you can use the WM_GETTEXT API message to get the text from the edit control...

Cheers,

Raymond,

ASKER CERTIFIED SOLUTION
Avatar of Radler
Radler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of delpro

ASKER

It is Controls[i].GetTextBuf( Txt, 127 ); and not
  Controls[i].GetTextBuffer( Txt, 127 );