Drawing a Rounded Rectangle in a VCL Forms Application
Go Up to How To Build a VCL Forms Application with Graphics
This procedure draws a rounded rectangle in a VCL form.
- Create a VCL form and code the form's OnPaint event handler.
- Build and run the application.
To create a VCL form
- Choose File > New > Other > Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon.The VCL Forms Designer is displayed.
- In the Object Inspector, click the Events tab.
- Double-click the OnPaint event.The Code Editor displays with the cursor in the
TForm1.FormPaint
(Delphi) orTForm1::FormPaint
(C++) event handler block. - 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
- Save all files in your project; then choose Run > Run .
- The application executes, displaying a rounded rectangle in the upper left quadrant of the form.