RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TForm.MDIChildCount Property

Specifies the number of open MDI child forms.

Pascal
property MDIChildCount: Integer;
C++
__property int MDIChildCount;

Use MDIChildCount to get the number of open MDI child forms. 

MDIChildCount is meaningful only if the form is an MDI parent (that is, if the form's FormStyle property is set to fsMDIForm).  

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 CloseChildren. This is code for the
CloseChildrenClick handler.  When the user chooses the
CloseChildren command, all the MDI children of Form1 are
closed.
*/
void __fastcall TForm1::CloseChildrenClick(TObject *Sender)
{
  for(int i = MDIChildCount - 1; i >= 0; i--)
    MDIChildren[i]->Close();
}

void __fastcall TForm1::MyArrangeIconsClick(TObject *Sender)
{
  Form1->ArrangeIcons();
}

void __fastcall TForm1::MyCascadeClick(TObject *Sender)
{
  Form1->Cascade();
  }

 

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 CloseChildren. This is code for the
CloseChildrenClick handler.  When the user chooses the
CloseChildren command, all the MDI children of Form1 are
closed.
} 
procedure TForm1.CloseChildrenClick(Sender: TObject);
var
  I: Integer;
begin
  with Form1 do
    for I := MDIChildCount-1 downto 0 do
      MDIChildren[I].Close;
end;

procedure TForm1.MyArrangeIconsClick(Sender: TObject);
begin
  Form1.ArrangeIcons;
end;

procedure TForm1.MyCascadeClick(Sender: TObject);
begin
  Form1.Cascade;
end;

 

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