RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.FrameRect Method

Draws a rectangle using the Brush of the canvas to draw the border.

Pascal
procedure FrameRect(const Rect: TRect);
C++
__fastcall FrameRect(const TRect Rect);

Use FrameRect to draw a 1 pixel wide border around a rectangular region. FrameRect does not fill the interior of the rectangle with the Brush pattern. 

To draw a boundary using the Pen instead, use the Polygon method.  

C++ Examples: 

 

/*
The following code displays the text "Hello, world!" in a
rectangle defined by the coordinates (10, 10) and (100, 100).
After displaying the text with the TextRect method, the code
draws a black, vertical line frame around the rectangle.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TRect TheRect = Rect(10,10,100,100);
  Canvas->TextRect(TheRect, 10, 10, "Hello World");
  Canvas->Brush->Color = clBlack;
  Canvas->FrameRect(TheRect);
}

 

Delphi Examples: 

{
The following code displays the text "Hello, world!" in a 
rectangle defined by the coordinates (10, 10) and (100, 100).
After displaying the text with the TextRect method, the code
draws a black, vertical line frame around the rectangle.
} 
procedure TForm1.Button1Click(Sender: TObject);
var TheRect: TRect;
begin
  TheRect := Rect(10,10,100,100);
  Form1.Canvas.TextRect(TheRect,10,10,'Hello, world!');
  Form1.Canvas.Brush.Color := clBlack;
  Form1.Canvas.FrameRect(TheRect);
end;

 

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