RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TScreen.CustomForms Property

Lists all the forms and property pages that are currently displayed in the application.

Pascal
property CustomForms [Index: Integer]: TCustomForm;
C++
__property TCustomForm CustomForms[int Index];

Use CustomForms to access a form or property page by index. The value of Index is a number between zero (the first custom form) and CustomFormCount - 1. CustomForms can be used with CustomFormCount when an application needs to iterate over all its forms and property pages. 

Unlike the Forms property, CustomForms lists TCustomForm descendants that do not derive from TForm (such as property pages).

Warning: The order in which CustomForms lists its forms is affected by the Z order of the forms. Do not change the Z order of forms when using CustomForms to iterate over the forms in an application.
 

C++ Examples: 

 

/*
The following code adds the name of all forms and dialogs on
the screen to ListBox1 when Button1 is clicked.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 0; i < Screen->CustomFormCount; i++)
    ListBox1->Items->Add(Screen->CustomForms[i]->Name);
}

 

Delphi Examples: 

{
The following code adds the name of all forms and dialogs on
the screen to ListBox1 when Button1 is clicked.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Screen.CustomFormCount-1 do
    ListBox1.Items.Add(Screen.CustomForms[I].Name);
end;

 

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