RAD Studio VCL Reference
|
Indicates the horizontal size of the screen in pixels.
property Width: Integer;
__property int Width;
Read Width 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]->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!
|