Forms in Delphi, as in other Windows programming environments, are the starting point for the vast majority of applications. Forms are instances of the TForm class. They have many properties as follows:


A form can be displayed on screen as either a non-modal or a modal form. A modal form or window is one that takes the focus and must be closed before the application can return to the main form. Modal windows are used for message boxes and for many dialogue boxes as well. Forms with components on them like edit boxes and buttons are usually modeless, they do not have to be closed before the application can proceed. It is generally good practice to maintain this arrangement so users get what they expect and are not confused.

Form Style

This property has four possible values:

Border Style

This property has six possible settings:

Differences in form choice are not seen until the application is run. 

Border Icons

The default border icons for a form are one for the system menu in the top left corner and the Minimise, Maximise and Close buttons in the top right. The BorderIcons property allows these to be turned off or on as required (the Close button property cannot be changed). A fifth icon is available to provide 'What's This?' help, but only if the Minimise and Maximise buttons are disabled.

If the System Menu icon is disabled all the icons in the top right of the form are also disabled. 

The differences between the type of form and their border icons can be seen in this simple example:


A form can be placed in various locations in an application:

Of these the most common are probably poDesigned and poCentre. 


The size of a form can be determined by not only the Height and Width properties but also by ClientWidth and ClientHeight, which refer to the area inside borders, scroll bars and the title bar. The constraints property allows maximum and minimum height and width values to be determined so the user cannot resize a form beyond these limits.


Scroll bars are added automatically at run-time if the components on the form are not visible - this feature can be turned off by setting the AutoScroll property to False. The HorzScrollBar and VertScrollBar properties have several of their own properties, the most significant of which is Range. The Range property of a scroll bar determines the limit of scrolling within a form. 


A form can be scaled at run-time by using the ScaleBy method. This takes two parameters giving the scaling factor, for example (75, 100) will reduce size by three quarters while (150,100) will increase it by half as much again; all the components inside the form will be scaled accordingly. This can have unpredictable results on the readability of a form because objects on screen in Windows are measured in pixels so some truncation may take place. 

Forms and Project Options

To change the settings for a project choose Project/Options and select from the tabs. To change the main form, the one that a user sees first, select from the drop-down list:

DFM Files

A form can be viewed as text through the .dfm file for the form (Delphi Form Module). The dfm file provides the definition of the form properties and is converted to binary form before being incorporated into a program. To view the text definition of a file right click on a form to bring up the short cut menu and choose the View As Text option. To convert the text back to a form right click the text and choose View As Form. Here is one example:

object Form1: TForm1
  Left = 192
  Top = 107
  Width = 405
  Height = 216
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
  Left = 16
  Top = 160
  Width = 32
  Height = 13
  Caption = 'Label1'
 object Calendar1: TCalendar
  Left = 16
  Top = 24
  Width = 320
  Height = 120
  StartOfWeek = 0
  TabOrder = 0
  OnChange = Calendar1Change
 object Button1: TButton
  Left = 304
  Top = 152
  Width = 75
  Height = 25
  Caption = 'Exit'
  TabOrder = 1
  OnClick = Button1Click

This is a simple form with just two objects, a button and a calendar:

Back to Delphi Menu