String with the text or caption for the control.
Source position: controls.pp line 1554
protected property TControl.Text : TCaption |
This is the character string, shown in controls with visible text content (TEdit...).
Remark: | BEWARE: In other controls it can be the Name or Caption of the control, quite tricky to use. |
The Delphi VCL implementation stores Text mostly in the widgets, using the virtual Get/SetTextBuf methods to exchange text between widgets and VCL. This means a lot of text copies and message handling in WM_GETTEXT and WM_SETTEXT.
The LCL instead (typically) stores Text in a field of the control, and transfers it from/to the widgets only when required.
To maintain VCL compatibility, the virtual RealGet/SetText methods have been introduced, which read or write the Caption string directly.
The default Get/SetTextBuf implementation calls the RealGet/SetText methods, resulting in a string-to-PCHAR and another PCHAR-to-string conversion. But as long as Get/SetTextBuf is not overridden, Get/SetText can (and does) safely call RealGet/SetText immediately, to avoid the mentioned conversions.
To keep things optimal, LCL components should always override RealGet/SetText; Get/SetTextBuf is only kept for compatibility.
CT Web help |
CodeTyphon Studio |