Difference between revisions of "TForm"

From Lazarus wiki
Jump to navigationJump to search
(Link)
(One intermediate revision by one other user not shown)
Line 3: Line 3:
 
'''TForm''' is the [[Class|class]] of a form object. All forms created at design time can be derived from TForm.
 
'''TForm''' is the [[Class|class]] of a form object. All forms created at design time can be derived from TForm.
  
The form represents a window or dialog box that forms the user interface of an application. It is the container on which all other components (e.g. [[TButton|buttons]], [[TLabel|labels]], [[TEdit|edit fields]], [[TImage|images]]...) can be inserted.
+
The form represents a window or dialog box that forms the user interface of an [[Application|application]]. It is the container on which all other components (e.g. [[TButton|buttons]], [[TLabel|labels]], [[TEdit|edit fields]], [[TImage|images]]...) can be inserted.
  
 
A new TForm can be created using [[IDE Window: New Item|File<nowiki>|</nowiki>new...]].
 
A new TForm can be created using [[IDE Window: New Item|File<nowiki>|</nowiki>new...]].
  
 
== Application ==
 
== Application ==
 +
 
Forms created at design time using [[IDE Window: New Item|File<nowiki>|</nowiki>new...]] or clicking the new Form button, will create a new class or unit. To make one form accessable from another requires the new form to be added to the uses section of the unit for first form. To prevent circular referencing when each form requires to be added to the uses of the other, this will need to be added to a uses section under implementation.
 
Forms created at design time using [[IDE Window: New Item|File<nowiki>|</nowiki>new...]] or clicking the new Form button, will create a new class or unit. To make one form accessable from another requires the new form to be added to the uses section of the unit for first form. To prevent circular referencing when each form requires to be added to the uses of the other, this will need to be added to a uses section under implementation.
 
At program start, the main form and any other form that has to be 'autocreated' is actually instantiated. The forms are started in the sequence they are listed in the project. Autocreate forms may be selected from available forms in [Project|Project Options|Forms]. If for some reason available forms do not list the form that should be autocreated, add the necessary  form name to the [[Program|program]]'s [[Uses|uses]] clause and add a line <tt>Application.CreateForm</tt> for that form.
 
At program start, the main form and any other form that has to be 'autocreated' is actually instantiated. The forms are started in the sequence they are listed in the project. Autocreate forms may be selected from available forms in [Project|Project Options|Forms]. If for some reason available forms do not list the form that should be autocreated, add the necessary  form name to the [[Program|program]]'s [[Uses|uses]] clause and add a line <tt>Application.CreateForm</tt> for that form.
  
 
The project source code PTest.lpr:  
 
The project source code PTest.lpr:  
<syntaxhighlight>
+
 
 +
<syntaxhighlight lang=pascal>
 
program PTest;
 
program PTest;
 
uses
 
uses
Line 31: Line 33:
  
 
== Properties ==
 
== Properties ==
 +
 
* [[Action]], [[ActiveControl]], [[Align]], [[AllowDropFiles]], [[AlphaBlend]], [[AlphaBlendValue]], [[Anchors]], [[AutoScroll]], [[AutoSize]], [[BiDiMode]], [[BorderIcons]], [[BorderStyle]], [[BorderWidth]], [[Caption]], [[ChildSizing]], [[Color]], [[Constraints]], [[Cursor]], [[DefaultMonitor]], [[DesignTimePPI]], [[DockSite]], [[DragKind]], [[DragMode]], [[Enabled]], [[Font]], [[FormStyle]], [[Height]], [[HelpKeyword]], [[HelpType]], [[Hint]], [[HorzScrollBar]], [[Icon]], [[KeyPreview]], [[Left]], [[Menu]], [[Name]], [[ParentBiDiMode]], [[ParentFont]], [[PixelsPerInch]], [[PopupMenu]], [[PopupMode]], [[PopupParent]], [[Position]], [[Scaled]], [[SessionProperties]], [[ShowHint]], [[ShowInTaskBar]], [[Tag]], [[Top]], [[UseDockManager]], [[VertScrollBar]], [[Visible]], [[Width]], [[WindowState]]
 
* [[Action]], [[ActiveControl]], [[Align]], [[AllowDropFiles]], [[AlphaBlend]], [[AlphaBlendValue]], [[Anchors]], [[AutoScroll]], [[AutoSize]], [[BiDiMode]], [[BorderIcons]], [[BorderStyle]], [[BorderWidth]], [[Caption]], [[ChildSizing]], [[Color]], [[Constraints]], [[Cursor]], [[DefaultMonitor]], [[DesignTimePPI]], [[DockSite]], [[DragKind]], [[DragMode]], [[Enabled]], [[Font]], [[FormStyle]], [[Height]], [[HelpKeyword]], [[HelpType]], [[Hint]], [[HorzScrollBar]], [[Icon]], [[KeyPreview]], [[Left]], [[Menu]], [[Name]], [[ParentBiDiMode]], [[ParentFont]], [[PixelsPerInch]], [[PopupMenu]], [[PopupMode]], [[PopupParent]], [[Position]], [[Scaled]], [[SessionProperties]], [[ShowHint]], [[ShowInTaskBar]], [[Tag]], [[Top]], [[UseDockManager]], [[VertScrollBar]], [[Visible]], [[Width]], [[WindowState]]
  
 
== Events ==
 
== Events ==
 +
 
* [[Action]], [[ActiveControl]], [[Constraints]], [[Menu]], [[OnActivate]], [[OnChangeBounds]], [[OnClick]], [[OnClose]], [[OnCloseQuery]], [[OnConstrainedResize]], [[OnContextPopup]], [[OnCreate]], [[OnDblClick]], [[OnDeactivate]], [[OnDestroy]], [[OnDockDrop]], [[OnDockOver]], [[OnDragDrop]], [[OnDragOver]], [[OnDropFiles]], [[OnEndDock]], [[OnGetSiteInfo]], [[OnHelp]], [[OnHide]], [[key down | OnKeyDown]], [[OnKeyPress]], [[OnKeyUp]], [[OnMouseDown]], [[OnMouseEnter]], [[OnMouseLeave]], [[OnMouseUp]], [[OnMouseWheel]], [[OnMouseWheelDown]], [[OnMouseWheelUp]], [[OnPaint]], [[OnResize]], [[OnShortCut]], [[OnShow]], [[OnShowHint]], [[OnStratDock]], [[OnUnDock]], [[OnUTF8KeyPress]], [[OnWindowStateChange]], [[PopupMenu]], [[PopupParent]]
 
* [[Action]], [[ActiveControl]], [[Constraints]], [[Menu]], [[OnActivate]], [[OnChangeBounds]], [[OnClick]], [[OnClose]], [[OnCloseQuery]], [[OnConstrainedResize]], [[OnContextPopup]], [[OnCreate]], [[OnDblClick]], [[OnDeactivate]], [[OnDestroy]], [[OnDockDrop]], [[OnDockOver]], [[OnDragDrop]], [[OnDragOver]], [[OnDropFiles]], [[OnEndDock]], [[OnGetSiteInfo]], [[OnHelp]], [[OnHide]], [[key down | OnKeyDown]], [[OnKeyPress]], [[OnKeyUp]], [[OnMouseDown]], [[OnMouseEnter]], [[OnMouseLeave]], [[OnMouseUp]], [[OnMouseWheel]], [[OnMouseWheelDown]], [[OnMouseWheelUp]], [[OnPaint]], [[OnResize]], [[OnShortCut]], [[OnShow]], [[OnShowHint]], [[OnStratDock]], [[OnUnDock]], [[OnUTF8KeyPress]], [[OnWindowStateChange]], [[PopupMenu]], [[PopupParent]]
  
 
== See also ==
 
== See also ==
 +
 
* [[doc:lcl/forms/tform.html|TForm doc]]
 
* [[doc:lcl/forms/tform.html|TForm doc]]
 
* [[Form Tutorial]]
 
* [[Form Tutorial]]

Revision as of 16:06, 21 November 2020

Deutsch (de) English (en) suomi (fi) français (fr) 日本語 (ja) русский (ru) 中文(中国大陆)‎ (zh_CN)

TForm is the class of a form object. All forms created at design time can be derived from TForm.

The form represents a window or dialog box that forms the user interface of an application. It is the container on which all other components (e.g. buttons, labels, edit fields, images...) can be inserted.

A new TForm can be created using File|new....

Application

Forms created at design time using File|new... or clicking the new Form button, will create a new class or unit. To make one form accessable from another requires the new form to be added to the uses section of the unit for first form. To prevent circular referencing when each form requires to be added to the uses of the other, this will need to be added to a uses section under implementation. At program start, the main form and any other form that has to be 'autocreated' is actually instantiated. The forms are started in the sequence they are listed in the project. Autocreate forms may be selected from available forms in [Project|Project Options|Forms]. If for some reason available forms do not list the form that should be autocreated, add the necessary form name to the program's uses clause and add a line Application.CreateForm for that form.

The project source code PTest.lpr:

program PTest;
uses
  Forms,
  UMainForm,
  UOtherForm;
{$R *.res}

begin
  Application.Title:='Test';
  RequireDerivedFormResource := True;
  Application.Initialize();
  Application.CreateForm(TMainForm, MainForm);
  Application.CreateForm(TOtherForm, OtherForm);
  Application.Run();
end.

Properties

Events

See also