| [Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | 
[Properties (by Name)] [Methods (by Name)] [Events (by Name)]
The base type for TFrame.
Source position: forms.pp line 313
type TCustomFrame = class(TCustomDesignControl)  | 
||
protected  | 
||
class procedure WSRegisterClass; override;  | 
  | 
Registers this component class with the current WidgetSet.  | 
procedure Notification(); override;  | 
  | 
Adds or removes an action list for the control.  | 
procedure SetColor(); override;  | 
  | 
Sets the value for the Color property.  | 
procedure SetParent(); override;  | 
  | 
Sets the value for the Parent property.  | 
procedure SetParentBackground(); override;  | 
  | 
Sets the value for the ParentBackground property.  | 
procedure CMParentColorChanged(); message;  | 
  | 
Handles the CM_PARENTCOLORCHANGED message for the control.  | 
procedure DefineProperties(); override;  | 
  | 
Defines non-published properties that are included in LCL component streaming.  | 
procedure CalculatePreferredSize(); override;  | 
  | 
Gets the preferred height and width for the control used during auto-sizing.  | 
procedure UpdateOpaque;  | 
  | 
Updates control style flags to reflect the transparency for the frame.  | 
public  | 
||
constructor Create(); override;  | 
  | 
Constructor for the class instance.  | 
procedure GetChildren(); override;  | 
  | 
Invokes Proc for all Controls and also for all Components without a Parent.  | 
class function GetControlClassDefaultSize; override;  | 
  | 
Gets the default dimensions for a new instance of the class.  | 
property ParentBackground: Boolean;  | 
  | 
Indicates if the control uses the background from the parent.  | 
end;  | 
  | 
The base type for TFrame.  | 
|
| | | ||
  | 
Provides a designer surface for scaling and layout of its child controls.  | 
|
| | | ||
  | 
Implements a windowed control with scroll bars.  | 
|
| | | ||
  | 
The base class for windowed controls which paint themselves.  | 
|
| | | ||
  | 
Implements a windowed control which can contain other child controls.  | 
|
| | | ||
  | 
The base class for visible controls.  | 
|
| | | ||
  | 
The base class for LCL components which have an associated widget.  | 
|
| | | ||
| | | ||
| | | ||
TCustomFrame is a TCustomDesignControl descendant which implements the base class for TFrame. A Frame is a named container for related components. Groups of controls can be place on a frame, and re-used in your applications.
A Frame has behavior very similar to a Form. Their unique ability is that they can be embedded into forms or other frames in the designer. Like forms, they are stored in two separate files: the code is stored in a .pas unit file, and the design is stored in a .lfm file.
Frames can be created and designed in the Lazarus IDE by creating a new Frame module, and using the unit in your application. An existing frame can be added using the TFrame component on the Standard tab in the Lazarus IDE; you will be prompted for the TFrame class to use for the component.
Frames can also be created in code at run-time. They do not have to be installed in the Lazarus IDE. For example:
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; GroupBox1: TGroupBox; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { private declarations } Frame: TFrame; public { public declarations } end; var Form1: TForm1; implementation uses Unit2{TFrame1}, Unit3{TFrame2}, Unit4{TFrame3}; {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin Frame := TFrame1.Create(GroupBox1); Frame.Parent := GroupBox1; end; procedure TForm1.Button1Click(Sender: TObject); begin if not Assigned(Frame) then begin Frame := TFrame1.Create(GroupBox1); Frame.Parent := GroupBox1; end else if Frame is TFrame1 then begin Frame.Free; Frame := TFrame2.Create(GroupBox1); Frame.Parent := GroupBox1; end else if Frame is TFrame2 then begin Frame.Free; Frame := TFrame3.Create(GroupBox1); Frame.Parent := GroupBox1; end else begin FreeAndNil(Frame); end; end; end.
One drawback is that complex inheritance hierarchies for TFrame classes can be problematic; they do not propagate changes to all derived frames in a multi-level inheritance tree.
  | 
Frames can be designed like Forms and used like custom controls, without much coding or installation in the IDE.  | 
|
  | 
Provides a designer surface for scaling and layout of its child controls.  | 
| Version 4.0 | Generated 2025-05-03 | Home |