RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TForm.FormStyle Property

Determines the form's style.

Pascal
property FormStyle: TFormStyle;
C++
__property TFormStyle FormStyle;

Use FormStyle to get or set the form's style. FormStyle is one of the following values:

Value 
Meaning 
fsNormal  
The form is neither an MDI parent window nor an MDI child window.  
fsMDIChild  
The form is an MDI child window.  
fsMDIForm  
The form is an MDI parent window.  
fsStayOnTop  
This form remains on top of the desktop and of other forms in the project, except any others that also have FormStyle set to fsStayOnTop. If one fsStayOnTop form launches another, neither form will consistently remain on top.  

If the form is the main form of an MDI application, its FormStyle property must be set to fsMDIForm.

Note: It is not advisable to change FormStyle at runtime.
Warning: TGraphicControl descendants placed in the client area of a form with FormStyle set to fsMDIForm will not paint.
 

C++ Examples: 

 

/*
This example uses several forms. The first form has its
FormStyle property set to MDIForm. The others have their
FormStyle properties set to MDIChild and their Visible
properties set to true. Add a main menu component and name
one of the menu items MyArrangeIcons. This is code for the
MyArrangeIconsClick handler.  When the user chooses the
ArrangeIcons command, minimized child forms are arranged
so that they are evenly spaced and don't overlap.  DO NOT
name the menu items "ArrangeIcons" as that will override
the TForm method.
*/
void __fastcall TForm1::MyArrangeIconsClick(TObject *Sender)
{
  Form1->ArrangeIcons();
}
/*
This example ensures that the main form of the application
is an MDI parent:
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  if(FormStyle != fsMDIForm)
          FormStyle = fsMDIForm;
  if(FormStyle == fsMDIForm)
          Edit1->Text = "MDI form";
  else
    //This line never executes
    Edit1->Text = "Not an MDI form";
}
/*
This example uses three forms. The first form has its
FormStyle property set to MDIForm. The other two have their
FormStyle properties set to MDIChild and their Visible
properties set to true. Add a main menu component and name
one of the menu items TileForms. This is code for the
TileFormsClick handler.  When the user chooses the TileForms
command, the child forms tile vertically within the MDI frame
form.
*/
void __fastcall TForm1::TileFormsClick(TObject *Sender)
{
  TileMode = tbVertical;
  Tile();
}

 

Delphi Examples: 

{
This example uses several forms. The first form has its
FormStyle property set to MDIForm. The others have their
FormStyle properties set to MDIChild and their Visible
properties set to true. Add a main menu component and name
one of the menu items MyArrangeIcons. This is code for the
MyArrangeIconsClick handler.  When the user chooses the
ArrangeIcons command, minimized child forms are arranged
so that they are evenly spaced and don't overlap.  DO NOT
name the menu items "ArrangeIcons" as that will override
the TForm method.
} 
procedure TForm1.MyArrangeIconsClick(Sender: TObject);
begin
  Form1.ArrangeIcons;
end;
{
This example ensures that the main form of the application
is an MDI parent:
}
type
  TForm1 = class(TForm)
    Edit1: TEdit;
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

constructor TForm1.Create(AOwner : TComponent);

begin
  inherited Create(AOwner);
  if FormStyle <> fsMDIForm then
          FormStyle := fsMDIForm;
  if FormStyle = fsMDIForm then
          Edit1.Text := 'MDI form'
  else
    //This line never executes
    Edit1.Text := 'Not an MDI form';
end;
{
This example uses three forms. The first form has its
FormStyle property set to MDIForm. The other two have their
FormStyle properties set to MDIChild and their Visible
properties set to true. Add a main menu component and name
one of the menu items TileForms. This is code for the
TileFormsClick handler.  When the user chooses the TileForms
command, the child forms tile vertically within the MDI frame
form.
}
procedure TForm1.TileFormsClick(Sender: TObject);
begin
  TileMode := tbVertical;
  Tile;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!