Drawing a Rounded Rectangle in a Windows VCL Application
Go Up to How To Build a Windows VCL 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
- Open File > New > Windows VCL Application - Delphi
- 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.