Results 1 to 4 of 4

Thread: Polyline Help.

  1. #1

    Thread Starter
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411

    Polyline Help.

    I am using Polyline to draw a line to the screen. What i want to do is plot 2 points, for example, the user would click at one point on the screen, then at another spot on the screen. i would like to draw from the first point to the second point, but instead of stopping at the second point, continue drawing a line to the end of the screen along the same direction as the 2 points that were plotted


    drawing a straight horizontal line or vertical line would be easy to continue on because you just increase the size of the x or y respectively, but what about when its diagonal?

    I hope this was clear...
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  2. #2

    Thread Starter
    Hyperactive Member AAG's Avatar
    Join Date
    Aug 2000
    Location
    United States
    Posts
    411
    come on i know somebody knows this.
    This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)

  3. #3
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Go onto my website, and grab the sounds corny zip, and look at the maze editor. Then let me know what you need.
    Last edited by plenderj; Aug 17th, 2001 at 04:36 AM.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi AAG
    here is some code using a picture box and Line method. Am sure u can adapt for ur conditions
    Regards
    Stuart
    VB Code:
    1. Dim fbooDrawLine As Boolean
    2. Dim lsngPoint1X As Single
    3. Dim lsngPoint1Y As Single
    4. Dim lsngPoint2X As Single
    5. Dim lsngPoint2Y As Single
    6.  
    7. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.     If fbooDrawLine Then
    9.         lsngPoint2X = X
    10.         lsngPoint2Y = Y
    11.         Picture1.Line (lsngPoint1X, lsngPoint1Y)-(lsngPoint2X, lsngPoint2Y)
    12.         DrawExtendedLine
    13.         fbooDrawLine = False
    14.     Else
    15.         lsngPoint1X = X
    16.         lsngPoint1Y = Y
    17.         fbooDrawLine = True
    18.     End If
    19. End Sub
    20.  
    21. Private Sub DrawExtendedLine()
    22.     Dim mAngle As Single
    23.     Dim bStart As Single
    24.     Dim lsngNewX As Single
    25.     Dim lsngNewY As Single
    26.  
    27.     mAngle = (lsngPoint2Y - lsngPoint1Y) / (lsngPoint2X - lsngPoint1X)
    28.     bStart = lsngPoint2Y
    29.     lsngNewX = Picture1.ScaleWidth
    30.     lsngNewY = mAngle * (lsngNewX - lsngPoint2X) + bStart
    31.     Picture1.Line -(lsngNewX, lsngNewY)
    32. End Sub
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

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