[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Controls' (#lcl)

# TControl.RealSetText

Sets the value for the Caption property.

## Declaration

Source position: controls.pp line 1513

`protected procedure TControl.RealSetText(`
`const Value: TCaption`
`); virtual;`

## Arguments

`Value` |  | The string value to store in the Text / Caption properties.

## Description

RealSetText is a method used to apply the TCaption value in AValue to the text or caption for the control. RealSetText is called by the private SetText method, when SetTextBuf has not been overridden.

Notes on TControl.Caption, TControl.Text, et. al.

The Delphi VCL implementation relies on the virtual GetTextBuf and SetTextBuf methods to exchange text for controls.. This requires a lot of (unnecessary) copies to move values between Text and Caption.

The LCL uses strings to exchange text values because it is more efficient. To maintain VCL compatibility, the virtual RealGetText and RealSetText methods were introduced. These functions use the LCLInterface. The default GetTextBuf and SetTextBuf implementations calls the RealGetText and RealSetText methods as needed. As long as the GetTextBuf and/or SetTextBuf aren't overridden, GetText and SetText call RealGetText and RealSetText to avoid copying PChar values.

To keep things optimal, LCL implementations should always override RealGetText and RealSetText. GetTextBuf and SetTextBuf are only kept for compatibility with Delphi code.

## See also

TControl.Caption |  | The text displayed for the control.
TControl.Text |  | String with the text or caption for the control.
TControl.RealGetText |  | Returns the Caption property.
TControl.SetTextBuf |  | Updates the Text property from a PChar buffer.
TControl.GetTextBuf |  | Copy the Text property into Buffer.