Results 1 to 4 of 4

Thread: ~Curved Lines~

  1. #1

    Thread Starter
    Lively Member Gherkin's Avatar
    Join Date
    Aug 2001
    Location
    Gherkin Land
    Posts
    65

    ~Curved Lines~

    Hi Everyone!

    Does anyone know how to draw curved lines in Visual Basic?

    Thanks a lot!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Play around with this and see if you can come up with something you like
    VB Code:
    1. Private Declare Function Arc Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
    2. Private Sub Form_Load()
    3.     'KPD-Team 1998
    4.     'URL: [url]http://www.allapi.net/[/url]
    5.     'E-Mail: [email][email protected][/email]
    6.     'Set graphical mode to persistent
    7.     Me.AutoRedraw = True
    8.     'Draw to arcs
    9.     Arc Me.hdc, 0, 0, 100, 100, 100, 50, 50, 100
    10.     Arc Me.hdc, 49, 49, 149, 149, 49, 99, 99, 49
    11. End Sub

  3. #3
    jim mcnamara
    Guest
    You can also draw Bezier curves:
    Code:
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    Private Declare Function PolyBezier Lib "gdi32.dll" (ByVal hdc As Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
    Private Declare Function PolyBezierTo Lib "gdi32.dll" (ByVal hdc As Long, lppt As POINTAPI, ByVal cCount As Long) As Long
    Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Any) As Long
    Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function PolyPolygon Lib "gdi32.dll" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long
    Private Sub Form_Paint()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim pts(0 To 6) As POINTAPI
        Dim numpoints(0 To 1) As Long
        'set the coördinates
        pts(0).x = 0: pts(0).y = 100
        pts(1).x = 125: pts(1).y = 75
        pts(2).x = 255: pts(2).y = 148
        pts(3).x = 219: pts(3).y = 199
        pts(4).x = 315: pts(4).y = 203
        pts(5).x = 236: pts(5).y = 16
        pts(6).x = 122: pts(6).y = 123
        'set the forecolor to green
        Me.ForeColor = vbGreen
        'draw the bézier
        PolyBezier Me.hdc, pts(0), 7
        'set the forecolor to red
        Me.ForeColor = vbRed
        'move the 'active' point
        MoveToEx Me.hdc, 200, 25, ByVal 0&
        'set the coördinates
        pts(0).x = 125: pts(0).y = 50
        pts(1).x = 123: pts(1).y = 200
        pts(2).x = 102: pts(2).y = 100
        pts(3).x = 102: pts(3).y = 100
        pts(4).x = 312: pts(4).y = 75
        pts(5).x = 289: pts(5).y = 125
        'draw the bézier
        PolyBezierTo Me.hdc, pts(0), 6
        'set the forecolor to blue
        Me.ForeColor = vbBlue
        'set the points belonging to the rectangle
        pts(0).x = 20: pts(0).y = 10
        pts(1).x = 200: pts(1).y = 10
        pts(2).x = 200: pts(2).y = 190
        pts(3).x = 20: pts(3).y = 190
        numpoints(0) = 4
        'set the points belonging to the triangle
        pts(4).x = 100: pts(4).y = 0
        pts(5).x = 50: pts(5).y = 100
        pts(6).x = 150: pts(6).y = 100
        numpoints(1) = 3
        'draw the polygons
        PolyPolygon Me.hdc, pts(0), numpoints(0), 2
    End Sub

  4. #4

    Thread Starter
    Lively Member Gherkin's Avatar
    Join Date
    Aug 2001
    Location
    Gherkin Land
    Posts
    65
    Thanks! I'll try it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width