RAD Studio
ContentsIndex
PreviousUpNext
Drawing a Rounded Rectangle in a VCL Forms Application

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 FileNewOtherDelphi 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 RunRun.
  2. The application executes, displaying a rounded rectangle in the upper left quadrant of the form.

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