-
Mouse position
Hi,
How to:
If I move the mouse pointer over a specific X and Y coordinate, I want to run a function.
If I have a button on my form and I move the mouse pointer over the buttons (x , y) coordinates the function must run. Then if the mouse is moved away from the button a different function must run.
Hope you understand what I'm trying to say!
Thanks for you're help in advance!
-
Take a look at:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
API
-
You may also call your function from the MouseMove event of the form or control over which you're moving the mouse.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
yeah... the mousemove event's probably easier.
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
if X = [your x value] and Y = [your y value] then
call Myfunction
else
call MyOtherfunction
end if
End Sub
However, if you only want the program to call the function while the mouse is over a particular button, you have to use the Command1.Top and Command1.Left declarations:
if X = Command1.Left and Y = Command1.Top then
call Myfunction
else
call MyOtherfunction
end if
However, even if you use exactly that statement the program will only call the function on that one point (Command1.Left, Command1.Top). So you'll have to do some math with the Command1.Height and Command1.Width variables.
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks