Results 1 to 7 of 7

Thread: Problem with MouseDown on PictureBox

  1. #1

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Hi,
    I've got a weird problem with the mousedown event on a picturebox.
    I'm using the mouse to draw a line on the picturebox while the mousebutton is pressed.
    Im saving the startposition (x,y) at mousedown and use the x,y at mousemove to draw the line.
    That works fine.
    If I start outside this picturebox with mousepressed and move into the box, nothing is shown, so far so good.
    But If I'm start anywhere on the menu (mousedown over menu), the line is printed starting
    at an old startposition as soon as I move onto the box.
    ?????????????????????
    Does anybody have a clue on that?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Gig Harbor, WA; Posts: 89950
    Posts
    360
    It appears as though your app, has mistaken the menu for the picture box. Interesting.

    Can you clear the (x, y) coordinates on the mouse down click event for the menu? Or Clear it on the mouse down <> Picturebox?
    Mahalo
    VB6(SP5), VC++, COBOL, Basic, JAVA
    MBA, MCSD, MCSE, A+
    Computer Forensics

  3. #3
    Guest
    Post your code up. As Lee M suggested, maybe you're not clearing it, or if you are, it's not in the right event.

  4. #4
    Guest
    Try the following.
    Code:
    Private px As Single
    Private py As Single
    Private InBox As Boolean
    
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            px = X
            py = Y
            InBox = True
        End If
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If InBox = True Then
            If Button = 1 Then
                Picture1.Line (px, py)-(X, Y)
                px = X
                py = Y
            End If
        End If
    End Sub
    
    Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        InBox = False
    End Sub

  5. #5

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    OK, here's the code:
    Karte is the PictureBox
    BearDistLine is a LineObject
    Code:
    Private Sub Karte_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        BearDistLine.X1 = X
        BearDistLine.Y1 = Y
    End Sub
    Private Sub Karte_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        BearDistLine.X2 = X
        BearDistLine.Y2 = Y
        BearDistLine.Visible = True
    End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6
    Guest
    Did my above code work for you?

  7. #7

    Thread Starter
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Will try that, Megatron
    Thanks

    And, I'm did reset my systemclock, you are fast but not THAT fast ;-)
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

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