|
-
Aug 20th, 2002, 10:01 PM
#1
Thread Starter
New Member
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.
-
Aug 20th, 2002, 10:15 PM
#2
Junior Member
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.
-
Aug 20th, 2002, 11:17 PM
#3
Good Ol' Platypus
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)
-
Aug 21st, 2002, 12:11 AM
#4
Junior Member
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
-
Aug 21st, 2002, 12:43 AM
#5
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|