CodeItBetter Programming Another VB Programming Blog

How to draw Ellipse using API

Posted on December 23, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'Graphics - How to draw Ellipse using API
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
Filed under: Graphics Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.