Results 1 to 5 of 5

Thread: Using PSET to draw in a PICTURE BOX

  1. #1
    Guest

    Question

    Can someone tell me the how to make it so that when the mouse is clicked in a picture box, and held down, it will draw a line wherever the mouse is moved. If you could give me the code, or a link to a tutorial, it would greatly apprciated. Thanks...

  2. #2
    Guest

    Lightbulb

    I think you mean the line is only inside of the picturebox, so here's something: (not tested and no pset)

    Dim OldX as integer
    Dim OldY as integer

    Private Sub Picture1_MouseDown(Button as integer, Shift as integer, X as integer, Y as integer)
    If Button <> 1 then Exit sub
    OldX=X
    OldY=Y
    End Sub

    Private Sub Picture1_MouseMove(Button as integer, Shift as integer, X as integer, Y as integer)
    If Button <> 1 then Exit sub
    Picture1.Line (OldX, OldY)-(X,Y)
    OldX=X
    OldY=Y
    End Sub


    Hope this is what you searched for. If you want that the picture won't be rubbed away, put Autoredraw on.

  3. #3
    Guest

    Question I think im wrong...

    I dont think im doing it right, could you go a little more in depth?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Post

    Try this:
    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        CurrentX = X: CurrentY = Y
    End Sub
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then Line -(X, Y)
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest

    Wink Thanks

    Thanks, that was exactly what i was looking for!

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