RAD Studio for Microsoft .NET |  |

Drawing Rectangles and Ellipses in a VCL Forms Application
See Also
Collapse All

These procedures draw a rectangle and ellipse in a VCL form.

1. Create a VCL form.
2. Code the form's OnPaint event handler to draw a rectangle and ellipse.
3. Build and run the application.

To create a VCL form

1. Choose FileNewOtherDelphi for .NET ProjectsVCL Forms Application.
2. In the Object Inspector, click the Design tab, if necessary, to display Form1.

To write the OnPaint event handler

1. In the Object Inspector, click the Events tab.
2. Double-click the OnPaint event in the Miscellaneous category on the Events tab. The Code Editor displays with the cursor in the TForm1.FormPaint event handler block.
3. Enter the following event handling code:

Copy Code

    Canvas.Rectangle (0, 0, ClientWidth div 2, ClientHeight div 2);
    Canvas.Ellipse (0, 0, ClientWidth div 2, ClientHeight div 2);

To run the program

1. Save all files in your project.
2. Choose RunRun.
3. The application executes, displaying a rectangle in the upper left quadrant, with an ellipse in the middle of the rectangle.

See Also

VCL.NET Overview

Drawing a Rounded Rectangle in a VCL Forms Application

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!