RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Forms.Screen Variable

Represents a screen device.

Pascal
Screen: TScreen;
C++
TScreen Screen;

The Screen variable is a TScreen component that represents the screen of the system on which the application runs. By default, applications create a screen component based on information about the current screen device and assign it to Screen.  

C++ Examples: 

 

/*
The following code determines the height of all forms on the
screen and resizes any that are taller than the screen height.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 0; i < Screen->FormCount; i++)
  {
    if (Screen->Forms[i]->Top < 0)
    {
      Screen->Forms[i]->Height += Screen->Forms[i]->Top;
      Screen->Forms[i]->Top = 0;
    }
    if (Screen->Forms[i]->Left < 0)
    {
      Screen->Forms[i]->Width += Screen->Forms[i]->Left;
      Screen->Forms[i]->Left = 0;
    }
    if (Screen->Forms[i]->Left + Screen->Forms[i]->Width > Screen->Width)
      Screen->Forms[i]->Width = Screen->Width - Screen->Forms[i]->Left;
    if (Screen->Forms[i]->Top + Screen->Forms[i]->Height > Screen->Height)
      Screen->Forms[i]->Height = Screen->Height - Screen->Forms[i]->Top;
  }
}

 

Delphi Examples: 

{
The following code determines the height of all forms on the
screen and resizes any that are taller than the screen height.
}
procedure TForm1.Button1Click(Sender: TObject);
var I: Integer;
begin
with Screen do
  for I := 0 to FormCount-1 do
    begin
    if Forms[I].Top < 0 then
    begin
      Forms[I].Height := Forms[I].Height + Forms[I].Top;
      Forms[I].Top := 0;
    end;
    if Forms[I].Left < 0 then
    begin
      Forms[I].Width := Forms[I].Width + Forms[I].Left;
      Forms[I].Left := 0;
    end;
    if Forms[I].Left + Forms[I].Width > Width then
      Forms[I].Width := Width - Forms[I].Left;
    if Forms[I].Top + Forms[I].Height > Height then
      Forms[I].Height := Height - Forms[I].Top;
    end;
end;

 

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