Results 1 to 3 of 3

Thread: cursor tracking is offset!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Location
    Milwaukee, Wi
    Posts
    28

    Question

    Hi!

    i am using the GetCursorPos API to create a very simple paint program. I have a picturebox in my form and i look for a mousedown event. As long as the mouse is down, the getcursorpos api tracks the location of the cursor. It worked when i had the x,y locations displaying to two labels. But then i tried to use the pset function to draw a pixel at each x,y location. This is the part that doesnt work. The dots drawn in the picture box are offset from the real position of my mouse pointer. It also seems that it is offset by a very specific amount. i have the scalemode property of the picture box set to pixels. I also tried the SetPixelV API, but i get the same exact problem. The dots are offset from the real cursor position.


    please let me know whats wrong.

    shaba

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You have to subtract the position of the PictureBox and all parents. It's much easier to use the MouseMove ebent of the picture box to do such a thing (Especially if it should be easy):

    Code:
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 1 Then
            Picture1.PSet (X, Y), 255
        End If
    End Sub

  3. #3
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    Also...use SetCapture in the MouseDown event and ReleaseCapture in the MouseUp event, so that you keep getting the MouseMove events while the user drags.
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

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