Sign in Join
FPDoc Onlineexperiment

TControl.RealSetText procedure

Member of TControlprotectedIn unit Controls

Sets the value for the Caption property.

Declaration

pascal
procedure 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

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.