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

TCustomLabel

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Control used to show static text optionally using multiple lines.

Declaration

Source position: stdctrls.pp line 1555

type TCustomLabel = class(TGraphicControl)

protected

  class procedure WSRegisterClass; override;

  

Registers this component class with the current WidgetSet.

  function CanTab; override;

  

Always False, since you cannot tab into a label control.

  procedure DoDrawText(); virtual;

  

Performs actions needed to draw the text for the label.

  function HasMultiLine;

  

Checks for CR or LF characters in the label text for the control.

  procedure CalculatePreferredSize(); override;

  

Calculates the preferred size for the control using its anchoring and constraints.

  procedure CalculateSize();

  

Gets the height and width needed for the label text.

  procedure DoAutoSize; override;

  

For internal use only; call AdjustSize instead.

  function DialogChar(); override;

  

Performs actions needed to handle an accelerator key for the control.

  procedure TextChanged; override;

  

Performs actions when the CM_TEXTCHANGED message is handled for the control.

  procedure DoSetBounds(); override;

  

Performs a bounds change for the control.

  procedure FontChanged(); override;

  

Implements the OnChange event handler for the Font in the control.

  class function GetControlClassDefaultSize; override;

  

Gets the size used for new instances of the class.

  procedure WMActivate(); message;

  

Defers the focus to the control in the FocusControl property.

  procedure Notification(); override;

  

Handles a notification that a component used in the control has been added or removed.

  function GetLabelText; virtual;

  

Returns the string value in the Caption for the control.

  function GetTransparent;

  

Gets the value for the Transparent property.

  procedure SetFocusControl();

  

Sets the value for the FocusControl property.

  procedure SetLayout();

  

Sets the value for the Layout property.

  procedure SetShowAccelChar();

  

Sets the value for the ShowAccelChar property.

  procedure SetTransparent();

  

Sets the value for the Transparent property.

  procedure SetWordWrap();

  

Sets the value for the WordWrap property.

  procedure Loaded; override;

  

Performs actions when the component has been loaded using LCL component streaming.

  procedure UpdateSize;

  

Adjusts the size for the control based on settings in AutoSize and OptimalFill.

  property Alignment: TAlignment; [rw]

  

Horizontal text justification in the control (centered, left- or right-justified).

  property FocusControl: TWinControl; [rw]

  

The control associated with the label and its accelerator key (AccelChar).

  property Layout: TTextLayout; [rw]

  

Vertical alignment for control text (at the top, bottom, or center).

  property ShowAccelChar: Boolean; [rw]

  

Underlines the character in the label that acts as the accelerator or short cut key.

  property Transparent: Boolean; [rw]

  

Indicates whether the viewer can see through the control.

  property WordWrap: Boolean; [rw]

  

Allows the caption to wrap to multiple lines when it is longer than the available Width.

  property OptimalFill: Boolean; [rw]

  

If True, the font size is adjusted for optimal fill of the available space.

public

  constructor Create(); override;

  

Constructor for the class instance.

  function CalcFittingFontHeight();

  

Calculates the font height needed to fill the specified width and height constraints.

  function AdjustFontForOptimalFill;

  

Adjusts the font height for the control text to fill the available client area.

  procedure Paint; override;

  

Performs actions needed to draw the control on its Canvas.

  procedure SetBounds(); override;

  

Sets the bounds (Top, Left, Width, Height) for the control.

  property AutoSize: Boolean;

  

Enables or disables auto-sizing the control to its content.

  property Color: TColor;

  

Contains the color used for the background on the control.

end;

Inheritance

TCustomLabel

  

Control used to show static text optionally using multiple lines.

|

TGraphicControl

  

TGraphicControl is the base class for all lightweight controls.

|

TControl

  

The base class for visible controls.

|

TLCLComponent

  

The base class for LCL components which have an associated widget.

|

TComponent,IUnknown,IInterfaceComponentReference

|

TPersistent,IFPObserved

|

TObject

Description

TCustomLabel is a TWinControl descendant which specifies a control to display static text on a form. The value in the control is not editable visually, and can be used to label or describe another control or a container on the form. Since it cannot be edited, it is not allowed to receive the input focus. It can, however, be used to set focus to an associated control using an accelerator key defined in the Caption for the control.

TCustomLabel is the ancestor class for TLabel. Do not create instances of TCustomLabel; use the TLabel descendant.

Use TStaticText to display static text and respond to keyboard input directly in the control.

See also

HowToUseStdCtrls

  

How to use StdCtrls, ComCtrls or ExtCtrls.

TLabel

  

Control used to display static text, possibly in multiple lines.

TStaticText

  

Control used to display a text value which does not change.

TWinControl

  

Implements a windowed control which can contain other child controls.


Version 3.2 Generated 2024-02-25 Home