TControl.Text property
String with the text or caption for the control.
Declaration
property Text: TCaption read GetText write SetText;Description
This is the character string, shown in controls with visible text content (TEdit...).
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.
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
