TFrame class
Frames can be designed like Forms and used like custom controls, without much coding or installation in the IDE.
Declaration
TFrame = class(TCustomFrame)Inheritance
- TFrame
- TCustomFrame
- TCustomDesignControl
- TScrollingWinControl
- TCustomControl
- TWinControl
- TControl
- TLCLComponent
- TComponent
- TPersistent
- TObject
Description
TFrame is a
TCustomFrame descendant which implements 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 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.
TFrame contains a new property which indicates the LCL (Lazarus Component Library) version number used in the container. An overridden constructor is also introduced to initialize the value in the LCLVersion property. TFrame sets the visibility for properties defined in ancestor classes.
Properties
Align | published | Specifies the placement of the control on its Parent control. |
Anchors | published | The set of anchor definitions for this control. |
AutoScroll | published | Indicates whether scroll bars are automatically displayed or hidden when needed. |
AutoSize | published | Allows automatic adjustment of the size for the control, according to its content. |
BiDiMode | published | Indicates whether text controls use in bi-directional reading. |
BorderSpacing | published | Determines the inner and outer border spacing for this control. |
ChildSizing | published | Provides a grid (table) layout for the children of this control. |
ClientHeight | published | The height for the client area on the control. |
ClientWidth | published | The width of the client area for the control. |
Color | published | The background color for the control. |
Constraints | published | Contains the minimum and maximum Width and Height for the control. |
DesignTimePPI | published | Design-time Pixels Per Inch for the designer surface. |
DockSite | published | Allows controls to be drag-and-dock-ed into this control. |
DragCursor | published | The cursor shape shown during a drag operation. |
DragKind | published | Indicates the action performed for a drag operation: drag-and-drop or drag-and-dock. |
DragMode | published | Determines how a drag operation is started for the control. |
Enabled | published | Determines whether the control responds to mouse or keyboard input. |
Font | published | The font to be used for text display in this control. |
LCLVersion | published | LCL version number for the frame instance. |
ParentBackground | published | Indicates if the control uses the background from the parent. |
ParentBiDiMode | published | Indicates whether the BiDiMode settings in the Parent control are used. |
ParentColor | published | Use the Color from the Parent control, when enabled. |
ParentFont | published | Indicates if the Font from the Parent control is used in the control. |
ParentShowHint | published | If True, the value of ShowHint for the control will be the same as the one from the Parent. Default is True. |
PopupMenu | published | A context-sensitive menu that pops up when the right mouse button is clicked over this control. |
Scaled | published | Indicates if the design surface is scaled to reflect changes in display density (Pixels Per Inch). |
ShowHint | published | Enables Hint display for the control. |
TabOrder | published | Indicates the navigation order for the control when the user presses the Tab or Shift+Tab key. |
TabStop | published | Allows the user to navigate to / from the control by pressing the Tab or Shift+Tab keys. |
Visible | published | Allows the control, and all of its children, to be displayed or hidden. |
Methods
Create | public | Constructor for the class instance. |
Events
OnClick | published | Notification handler for mouse clicks. |
OnConstrainedResize | published | This handler can supply specific Constraints (size limits), when the control is resized. |
OnContextPopup | published | Invoked when a context-sensitive pop-up menu is requested. |
OnDblClick | published | Event handler signalled when a mouse double click occurs in the control. |
OnDockDrop | published | Event handler signalled for the drop of a control to be docked. |
OnDockOver | published | Event handler signalled when a control is moved over a docksite; determines whether the drop event is accepted or rejected. |
OnDragDrop | published | Event handler signalled when an object is dropped onto the control. |
OnDragOver | published | Event handler signalled when a control is dragged over the control instance. |
OnEndDock | published | Event handler signalled for the end of a drag-dock operation. |
OnEndDrag | published | Event handler signalled for the end of a drag-drop operation. |
OnEnter | published | Event handler signalled when the control receives focus. |
OnExit | published | Event handler signalled when the control loses focus. |
OnGetSiteInfo | published | Provides information about the DockSite for the control. |
OnMouseDown | published | Event handler signalled when a mouse down event is handled for the control. |
OnMouseEnter | published | Event handler signalled when the mouse pointer has entered the control. |
OnMouseLeave | published | Event handler signalled when the mouse pointer has left the control. |
OnMouseMove | published | Event handler signalled when the mouse pointer is moved in the control. |
OnMouseUp | published | Event handler signalled when a mouse up event is handled for the control. |
OnMouseWheel | published | Event handler for mouse wheel turned. |
OnMouseWheelDown | published | Event handler signalled for a downward movement of the mouse wheel. |
OnMouseWheelUp | published | Event handler signalled for an upward movement of the mouse wheel. |
OnMouseWheelHorz | published | Event handler signalled for a horizontal movement of the mouse wheel. |
OnMouseWheelLeft | published | Event handler signalled for a leftward movement of the mouse wheel. |
OnMouseWheelRight | published | Event handler signalled for a rightward movement of the mouse wheel. |
OnResize | published | Notification handler for a resize of the control. |
OnStartDock | published | Event handler for the start of a docking operation. |
OnStartDrag | published | Event handler signalled for the start of a dragging operation. |
OnUnDock | published | Event handler signalled before a control is undocked from its DockSite. |
Inherited
From TCustomFrame (13)
CalculatePreferredSize CMParentColorChanged DefineProperties FixFrameFontsPPI GetChildren GetControlClassDefaultSize Loaded Notification SetColor SetParent SetParentBackground UpdateOpaque WSRegisterClass
From TCustomDesignControl (4)
From TScrollingWinControl (24)
AlignControls AutoScrollEnabled CalculateAutoRanges ClientToScreen ComputeScrollbars CreateWnd Destroy DestroyWnd DoOnResize GetClientScrollOffset GetLogicalClientRect GetPreferredSizeClientFrame HorzScrollBar Resizing ScreenToClient ScrollBy ScrollInView SetAutoScroll SetAutoSize UpdateScrollbars VertScrollBar WMHScroll WMSize WMVScroll
From TCustomControl (7)
BorderStyle Canvas FontChanged OnPaint Paint PaintWindow WMPaint
From TWinControl (218)
AddControl AdjustClientRect AllAutoSized AutoSizeDelayed AutoSizeDelayedHandle AutoSizeDelayedReport AutoSizePhases BeginUpdateBounds BorderWidth BoundsLockCount BroadCast Brush BrushCreated CachedClientHeight CachedClientWidth CanFocus CanSetFocus CanTab ChangeScale ChildClassAllowed ChildHandlesCreated ChildKey ClientRectNeedsInterfaceUpdate CMBiDiModeChanged CMBorderChanged CMDoubleBufferedChanged CMEnabledChanged CMEnter CMExit CMParentDoubleBufferedChanged CMShowHintChanged CMShowingChanged CMVisibleChanged CNChar CNKeyDown CNKeyUp CNSysKeyDown CNSysKeyUp ContainsControl ControlAtPos ControlCount ControlKeyDown ControlKeyUp Controls ControlsAligned CreateBrush CreateDockManager CreateHandle CreateParams CreateParented CreateParentedControl CreateSubClass CustomAlignInsertBefore CustomAlignPosition DefaultHandler DefWndProc DesignerDeleting DestroyHandle DialogChar DisableAlign DoAddDockClient DoAdjustClientRectChange DoAlignChildControls DoAllAutoSize DoAutoSize DoChildSizingChange DockClientCount DockClients DockDrop DockManager DockOver DoConstraintsChange DoDockClientMsg DoDockOver DoDragMsg DoEnter DoExit DoFlipChildren DoFloatMsg DoGetDockCaption DoKeyDownBeforeInterface DoKeyPress DoKeyUpBeforeInterface DoRemainingKeyDown DoRemainingKeyUp DoRemoveDockClient DoSendBoundsToInterface DoSendShowHideToInterface DoSetBounds DoubleBuffered DoUnDock DoUndockClientMsg DoUTF8KeyPress EnableAlign EndUpdateBounds EraseBackground FinalizeWnd FindChildControl FindNextControl FixDesignFontsPPIWithChildren FixupTabList FlipChildren Focused FormEndUpdated GetAdjustedLogicalClientRect GetBorderStyle GetChildrenRect GetClientOrigin GetClientRect GetControlIndex GetControlOrigin GetDeviceContext GetDockCaption GetEnumeratorControls GetEnumeratorControlsReverse GetMouseCapture GetParentHandle GetSiteInfo GetTabOrderList GetTextLen GetTopParentHandle Handle HandleAllocated HandleNeeded InitializeWnd InsertControl IntfGetDropFilesTarget IntfUTF8KeyPress Invalidate InvalidateBoundsRealized InvalidateClientRectCache InvalidatePreferredChildSizes IsClientHeightStored IsClientWidthStored IsControlMouseMsg IsFlipped IsResizing IsSpecialSubControl KeyDown KeyDownAfterInterface KeyDownBeforeInterface KeyPress KeyUp KeyUpAfterInterface KeyUpBeforeInterface LockRealizeBounds MainWndProc NotifyControls OnAlignInsertBefore OnAlignPosition OnGetDockCaption OnKeyDown OnKeyPress OnKeyUp OnUTF8KeyPress PaintControls PaintHandler PaintTo ParentDoubleBuffered ParentFormHandleInitialized ParentHandlesAllocated ParentWindow PerformTab RealGetText ReAlign RealizeBounds RealizeBoundsRecursive RealSetText ReloadDockedControl RemoveControl RemoveFocus Repaint ScaleBy ScaleControls ScrollBy_WS SelectFirst SelectNext SendDialogChar SendMoveSizeMessages SetBorderStyle SetBounds SetChildZPosition SetControlIndex SetDockManager SetFocus SetShape SetTempCursor ShowControl Showing UnlockRealizeBounds Update UpdateControlState UpdateDockCaption UpdateShowing UseDockManager UTF8KeyPress VisibleDockClientCount WindowHandle WMChar WMContextMenu WMDestroy WMEnter WMEraseBkgnd WMExit WMKeyDown WMKeyUp WMKillFocus WMMove WMNotify WMSetFocus WMShowWindow WMSysChar WMSysKeyDown WMSysKeyUp WMWindowPosChanged WndProc WriteLayoutDebugReport WSSetText
From TControl (310)
AccessibleDescription AccessibleName AccessibleRole AccessibleValue Action ActionChange ActionLink ActiveDefaultControlChanged AddHandler AddHandlerOnBeforeDestruction AddHandlerOnChangeBounds AddHandlerOnEnabledChanged AddHandlerOnEnabledChanging AddHandlerOnKeyDown AddHandlerOnMouseWheel AddHandlerOnResize AddHandlerOnVisibleChanged AddHandlerOnVisibleChanging AdjustSize AnchorAsAlign AnchorClient AnchoredControlCount AnchoredControls AnchorHorizontalCenterTo AnchorParallel AnchorSame AnchorSide AnchorSideBottom AnchorSideChanged AnchorSideLeft AnchorSideRight AnchorSideTop AnchorToCompanion AnchorToNeighbour AnchorVerticalCenterTo AssignTo AutoSizing AutoSizingAll AutoSizingLockCount BaseBounds BaseParentClientSize BeforeDestruction BeforeDragStart BeginAutoDrag BeginAutoSizing BeginDrag BoundsChanged BoundsRect BoundsRectForNewParent BringToFront CalculateDockSizes CanAutoSize Caption CaptureChanged CaptureMouseButtons ChangeBounds Changed CheckChildClassAllowed CheckNewParent CheckOnChangeBounds Click ClientOrigin ClientRect ClientToParent CMChanged CMCursorChanged CMHintShow CMHitTest CMMouseEnter CMMouseLeave CMParentBiDiModeChanged CMParentFontChanged CMParentShowHintChanged CMSysFontChanged CMTextChanged CNPreferredSizeChanged ColorIsStored ConstrainedResize ControlFontClass ControlOrigin ControlState ControlStyle ControlToScreen CreateAccessibleObject CreateControlBorderSpacing CreateFloatingDockSite Cursor DblClick DesktopFont DisableAutoSizing DoBorderSpacingChange DoCallKeyEventHandler DoCallMouseWheelEventHandler DoCallNotifyHandler Dock Docked DockOrientation DockTrackNoTarget DoContextPopup DoDock DoEndDock DoEndDrag DoFixDesignFontPPI DoMouseDown DoMouseUp DoMouseWheel DoMouseWheelDown DoMouseWheelHorz DoMouseWheelLeft DoMouseWheelRight DoMouseWheelUp DoOnChangeBounds DoOnParentHandleDestruction DoOnShowHint DoScaleFontPPI DoStartDock DoStartDrag DragCanceled DragDrop Dragging DragOver EditingDone EnableAutoSizing EnabledChanged EnabledChanging EndAutoSizing EndDrag ExecuteCancelAction ExecuteDefaultAction FindSubComponent FixDesignFontsPPI Floating FloatingDockSiteClass ForeignAnchorSideChanged FormIsUpdating GetAccessibleObject GetAction GetActionLinkClass GetAnchorsDependingOnParent GetCachedText GetCanvasScaleFactor GetChildAccessibleObjectAtPos GetColorResolvingParent GetCursor GetDefaultColor GetDefaultDockCaption GetDefaultHeight GetDefaultWidth GetDockEdge GetDragImages GetEnabled GetFloating GetFloatingDockSiteClass GetMousePosFromMessage GetPalette GetParentBackground GetParentComponent GetPopupMenu GetPreferredSize GetRGBColorResolvingParent GetScrolledClientRect GetSelectedChildAccessibleObject GetSidePosition GetTextBuf GetTopParent HandleObjectShouldBeVisible HasHelp HasParent Height HeightIsAnchored HelpContext HelpKeyword HelpType Hide Hint HostDockSite InitiateAction InvalidateControl InvalidatePreferredSize IsAParentAligning IsBorderSpacingInnerBorderStored IsCaptionStored IsControl IsControlVisible IsEnabled IsParentColor IsParentFont IsParentOf IsProcessingPaintMsg IsRightToLeft IsVisible Left LMCaptureChanged LoadedAll LRDockWidth ManualDock ManualFloat MouseCapture MouseDown MouseEnter MouseInClient MouseLeave MouseMove MouseUp OnChangeBounds OnEditingDone OnQuadClick OnShowHint OnTripleClick Parent ParentDestroyingHandle ParentFontChanged ParentToClient Perform PositionDockRect QuadClick ReadBounds ReadState Refresh RemoveAllHandlersOfObject RemoveHandler RemoveHandlerOnBeforeDestruction RemoveHandlerOnChangeBounds RemoveHandlerOnEnabledChanged RemoveHandlerOnEnabledChanging RemoveHandlerOnKeyDown RemoveHandlerOnMouseWheel RemoveHandlerOnResize RemoveHandlerOnVisibleChanged RemoveHandlerOnVisibleChanging ReplaceDockedControl RequestAlign Resize Scale96ToFont Scale96ToForm Scale96ToScreen ScaleConstraints ScaleDesignToForm ScaleFontsPPI ScaleFontTo96 ScaleFontToScreen ScaleFormTo96 ScaleFormToDesign ScaleScreenTo96 ScaleScreenToFont ScreenToControl SendToBack SessionProperties SetAction SetAlign SetAnchors SetBiDiMode SetBoundsKeepBase SetCursor SetDragMode SetEnabled SetHint SetInitialBounds SetName SetParentBiDiMode SetParentComponent SetTextBuf SetVisible SetZOrder ShouldAutoAdjust Show ShowHelp TBDockHeight Text TextChanged Top TripleClick UndockHeight UndockWidth UpdateAnchorRules UpdateBaseBounds UpdateMouseCursor UpdateRolesForForm UseRightToLeftAlignment UseRightToLeftReading UseRightToLeftScrollBar VisibleChanged VisibleChanging Width WidthIsAnchored WindowProc WMCancelMode WMLButtonDBLCLK WMLButtonDown WMLButtonQuadCLK WMLButtonTripleCLK WMLButtonUp WMMButtonDBLCLK WMMButtonDown WMMButtonQuadCLK WMMButtonTripleCLK WMMButtonUp WMMouseHWheel WMMouseMove WMMouseWheel WMRButtonDBLCLK WMRButtonDown WMRButtonQuadCLK WMRButtonTripleCLK WMRButtonUp WMXButtonDBLCLK WMXButtonDown WMXButtonQuadCLK WMXButtonTripleCLK WMXButtonUp
From TLCLComponent (6)
DecLCLRefCount GetWSComponentClass IncLCLRefCount LCLRefCount NewInstance WidgetSetClass
From TComponent (64)
_AddRef _Release CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetTypeInfo GetTypeInfoCount iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState
From TPersistent (4)
Assign FPOAttachObserver FPODetachObserver FPONotifyObservers
From TObject (35)
AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
