RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TScreen.Height Property

Indicates the vertical size of the screen in pixels.

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

Read Height to learn the size of the user's screen in pixels. The size or position of objects placed on the screen, can then be set to ensure that the objects fit on screen and don't look crowded.  

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]->Height > Screen->Height)
      Screen->Forms[i]->Height = Screen->Height;
    if (Screen->Forms[i]->Width > Screen->Width)
      Screen->Forms[i]->Width = Screen->Width;
  }
}

 

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].Width > Width then
      Forms[I].Width := Width;
    if Forms[I].Height > Height then
      Forms[I].Height := Height;
    if Forms[I].Width > Width then
      Forms[I].Width := Width;
    end;
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!