Home > How-To Library > Graphics

How to draw Ellipse using API

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
Option Explicit 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 Private Sub Form_Load() Dim X As Single Dim Y As Single AutoRedraw = True ' API functions always draw in pixels. ScaleMode = vbPixels ' Draw a background. DrawWidth = 3 X = -ScaleHeight - 5 Y = -5 Do While X <= ScaleWidth Line (X, Y)-Step(ScaleHeight + 10, ScaleHeight + 10), vbRed X = X + 20 Loop ' Draw a filled ellipse. DrawWidth = 5 FillStyle = vbFSSolid FillColor = vbYellow Ellipse hdc, ScaleWidth * 0.1, ScaleHeight * 0.1, ScaleWidth * 0.45, ScaleHeight * 0.45 ' Draw a hollow dotted ellipse. DrawWidth = 1 FillStyle = vbFSTransparent DrawStyle = vbDot Ellipse hdc, ScaleWidth * 0.55, ScaleHeight * 0.55, ScaleWidth * 0.9, ScaleHeight * 0.9 End Sub

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.