RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TPen.Width Property

Specifies the width of the pen in pixels.

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

Use Width to give the line greater weight. If you attempt to set Width to a value less than 0, the new value is ignored.

Note: The value of Width influences which values of Style are valid.
 

C++ Examples: 

 

/*
This example draws many rounded rectangles of various sizes
and colors on a form maximized to fill the entire screen:
*/
int x, y;  

void __fastcall TForm1::FormActivate(TObject *Sender)
{
  WindowState = wsMaximized;
  Timer1->Interval = 50;
  randomize();
}

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  x = random(Screen->Width - 10);
  y = random(Screen->Height - 10);
  Canvas->Pen->Color = (Graphics::TColor) random(65535);
  Canvas->Pen->Width = random(7);
  int Dx = random(400);
  int Dy = random(400);
  Canvas->RoundRect(x, y, x + Dx, y + Dy, Dx/2, Dy/2);
}

 

Delphi Examples: 

{
This example draws many rounded rectangles of various sizes
and colors on a form maximized to fill the entire screen:
} 
var
  X, Y, DX, DY: Integer;
procedure TForm1.FormActivate(Sender: TObject);
begin
  WindowState := wsMaximized;
  Timer1.Interval := 50;
  Randomize;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  X := Random(Screen.Width - 10);
  Y := Random(Screen.Height - 10);
  Canvas.Pen.Color := Random(65535);
  Canvas.Pen.Width := Random(7);
  DX := Random(400);
  DY := Random(400);
  Canvas.RoundRect(X, Y, X + DX, Y + DY, DX div 2, DY div 2);
end;

 

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