RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TPropertyPage.ClientWidth Property

Specifies the width (in pixels) of the form's client area.

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

Use ClientWidth to determine the width (in pixels) of the form's client area. The client area is the usable area inside the form's border. Set ClientWidth to change the width of the form's window based on the desired client area. To change the width of the form's window based on the total size of the window (including the border, status bar and so on), use the Width property instead.  

C++ Examples: 

 

/*
This example starts the form in a position scrolled so that
the right hand edge shows:
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  /* set the width of the form window to display 300 pixels in the client area */
  ClientWidth = 300;
  /* now set the range to twice the client width.
   This means that the form has a logical size
   that is twice as big as the physical window.
   Note that Range must always be at least as big as ClientWidth! */
  HorzScrollBar->Range = 600;
  /* start the form fully scrolled */
  HorzScrollBar->Position = HorzScrollBar->Range - ClientWidth;
  /* clicking the scroll arrows moves the form 10 pixels */
  HorzScrollBar->Increment = 10;
  HorzScrollBar->Visible = true;  // Show the scrollbar
}
/*
This example shows how to use a splitter to divide a form 
into resizable panes.  All objects on the form are created 
dynamically in the OnCreate event handler of the form. To 
run this example, add ExtCtrls and FileCtrl to the uses 
clause of the form’s implementation section.
Note that when creating a splitter dynamically at runtime, 
it is important to set its position to the appropriate side 
of the control it will resize.
*/
#include <Extctrls.hpp>
#include <Filectrl.hpp>

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TSplitter* ps = new TSplitter(Form1);
  TFileListBox* pflb = new TFileListBox(Form1);
  TDirectoryListBox* pdlb = new TDirectoryListBox(Form1);

  // Line up the directory list box on the left of the form.
  pdlb->Parent = Form1;
  pdlb->Align = alLeft;
  pdlb->Width = Form1->ClientWidth/3;

  // Now use the splitter to divide the directory pane from the file pane.
  ps->Parent = Form1;
  ps->Left = pdlb->Left + pdlb->Width + 1; // Move to right of directory list.
  ps->Align = pdlb->Align; // Give same alignment as directory list.

  // Each pane must be at least one quarter of the form's width.
  ps->MinSize = Form1->ClientWidth/4;

  // Finally, create the last pane - a file list box.
  pflb->Parent = Form1;
  pflb->Align = alClient;
  pdlb->FileList = pflb; // Link the file list box to the directory list box.
}

 

Delphi Examples: 

{
This example starts the form in a position scrolled so that
the right hand edge shows:
}
procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientWidth := 300;
  with HorzScrollBar do
  begin
    { Set the range to twice the ClientWidth of the form }
    { This means that the form’s logical size is twice as big }
    { as the physical window. }
    { Note that Range must always be larger than the ClientWidth }
    Range := 600; 
    Position := Range - ClientWidth; { start form out fully scrolled }
    Increment := 10;  { clicking the scroll arrows moves the form 10 pixels }
    Visible := True;  { Show the scrollbar }
  end;
end; 

 

{
This example shows how to use a splitter to divide a form 
into resizable panes.  All objects on the form are created 
dynamically in the OnCreate event handler of the form. To 
run this example, add ExtCtrls and FileCtrl to the uses 
clause of the form’s implementation section.
Note that when creating a splitter dynamically at runtime, 
it is important to set its position to the appropriate side 
of the control it will resize.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  Split: TSplitter;
  Files: TFileListBox;
  Dirs: TDirectoryListBox;
begin
  { first add a directory list box to the form }
  Dirs := TDirectoryListBox.Create(Form1);
  { line it up on the left of the form }
  Dirs.Parent := Form1;
  Dirs.Align := alLeft;
  Dirs.Width := Form1.ClientWidth div 3;
{ now add the splitter to divide the directory pane from the file pane }
  Split := TSplitter.Create(Form1);
  Split.Parent := Form1;
  { make sure the splitter is to the right of the directory list box! }
  Split.Left := Dirs.Left + Dirs.Width + 1;
  Split.Align := Dirs.Align; { give it the same alignment as the directory }
  { each pane must be at least one quarter of the form’s width }
  Split.MinSize := Form1.ClientWidth div 4;
  { Finally, create the last pane – a file list box }
  Files := TFileListBox.Create(Form1);
  Files.Parent := Form1;
  Files.Align := alClient;
  Dirs.FileList := Files; { link the file list box to the directory list box }
end;

 

ClientHeight 

ClientRect 

Width

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