Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleUse the Ellipse API function
Keywordsellipse, API, circle
CategoriesAPI, Graphics
 
API functions always draw in pixels so set the ScaleMode to vbPixels.

API drawing fuctions work surprisingly well with Visual Basic drawing properties (DrawWidth, FillStyle, etc.) so use the properties to define the appearance of the ellipse. Then call the Ellipse function.

 
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
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated