Results 1 to 5 of 5

Thread: Mouse Tracking

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    Cleveland OH
    Posts
    1

    Mouse Tracking

    Is there any way to get where on the form the mouse is and move an image accordingly.

    Code:
    Type POINTAPI 'Declare types
        x As Long
        y As Long
    End Type
    
    Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long 'Declare API
    This is just returning X,Y position across the screen not just the form. How can i get it to limit itself to just the form and then get the placement based on the x, y?

    Thanks.

  2. #2
    Junior Member
    Join Date
    Aug 2002
    Location
    Phoenix
    Posts
    30
    Simple subtraction.

    formX = mouseX - form1.left
    formY = mouseY - form1.top

    formMaxX = form1.left + form1.width
    formMaxY = form1.top + form1.height



    or something along those lines.
    I'm in college now.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Unfortunately this won't work as the .top and .left properties are the complete top left... meaning to the top-left of the ICON even. You can use GetWindowRect of the child window to the form, I believe.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Junior Member
    Join Date
    Aug 2002
    Location
    Phoenix
    Posts
    30
    or, you can make a command(cmdTopLeft), place it in the top left of form and set to not visible.

    mouseX - cmdTopLeft.left
    mouseY - cmdTopLeft.top

    cose enough
    I'm in college now.

  5. #5
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Use the ScaleTop and ScaleLeft properties of a form to get it's client upper left and right. Similarly, use the ScaleWidth and ScaleHeight properties to get the width and height of the client area. Finally, use the ScaleX and ScaleY functions of the form to scale the .Scale... properties from twips to pixels, like so:
    Code:
    X = Form1.ScaleX(Form1.ScaleLeft, vbTwips, vbPixels)
    Z.

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