Drawing a Rounded Rectangle in a VCL Forms Application

From RAD Studio
Jump to: navigation, search

Go Up to How To Build a VCL Forms Application with Graphics

This procedure draws a rounded rectangle in a VCL form.

  1. Create a VCL form and code the form's OnPaint event handler.
  2. Build and run the application.

To create a VCL form

  1. Choose File > New > Other > Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon.The VCL Forms Designer is displayed.
  2. In the Object Inspector, click the Events tab.
  3. Double-click the OnPaint event.The Code Editor displays with the cursor in the TForm1.FormPaint (Delphi) or TForm1::FormPaint (C++) event handler block.
  4. Enter the following event handling code:
Canvas.RoundRect(0, 0, ClientWidth div 2, ClientHeight div 2, 10, 10);
Canvas->RoundRect(0, 0, ClientWidth/2, ClientHeight/2, 10, 10 );

To run the program

  1. Save all files in your project; then choose Run > Run .
  2. The application executes, displaying a rounded rectangle in the upper left quadrant of the form.

See Also