• There are several DLL routines that support graphic
methods. The DLL function Ellipse allows us to draw an ellipse bounded by a pre-defined
• The Declare statement for the Ellipse function is:
Private Declare Function Ellipse Lib "gdi32"
Alias "Ellipse" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long,
ByVal X2 As Long, ByVal Y2 As Long) As Long
Note there are five arguments: hdc is the hDC handle for the
region (Form or Picture Box) being drawn to, (X1, Y1) define the upper left hand
corner of the rectangular region surrounding the ellipse and (X2,Y2) define the
lower right hand corner. The region drawn to must have its ScaleMode property
set to Pixels (all DLL drawing routine use pixels for coordinates).
• Any ellipse drawn with this routine is drawn using
the currently selected DrawWidth and ForeColor properties and filled according
to FillColor and FillStyle.
3 - Drawing Ellipses
Start a new application. Set the form’s ScaleMode property to Pixels.
Use the API Text Viewer to obtain the Declare statement for the Ellipse function
and copy it into the General Declarations area:
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal
X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Attach the following code to the Form_Resize event:
Private Sub Form_Resize()
Dim RtnValue As Long
RtnValue = Ellipse(Form1.hdc, 0.1 * ScaleWidth, 0.1 * ScaleHeight, 0.9 * ScaleWidth,
0.9 * ScaleHeight)
Run the application. Resize the form and see how the drawn ellipse takes on
new shapes. Change the form’s DrawWidth, ForeColor, FillColor, and FillStyle
properties to obtain different styles of ellipses.