Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
I use the X & Y values in the mouse move event to make a comments box follow
the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
This worked for me.
' In a regular module Public gX As Single, gY As Single ' In a userform Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) gX = X gY = Y Debug.Print CStr("Does " & CStr(X) & " = " & CStr(gX) & "?") Debug.Print CStr("Does " & CStr(Y) & " = " & CStr(gY) & "?") End Sub -- Tim Zych http://www.higherdata.com "Roger" wrote in message ... I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long Type POINTAPI x As Long y As Long End Type Sub ShowPos() Dim lRetVal As Long Dim Pos As POINTAPI lRetVal = GetCursorPos(Pos) MsgBox Pos.x & ", " & Pos.y End Sub This will retrieve and display the coordinates. -- Gary''s Student - gsnu200834 "Roger" wrote: I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
That was an example. Here is how I might implement this (not using globals).
' In a regular module Sub DisplayMouseCoordinates(ByVal X As Single, ByVal Y As Single) Debug.Print "X = " & CStr(X) Debug.Print "Y = " & CStr(Y) End Sub ' In a userform: Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Call DisplayMouseCoordinates(X, Y) End Sub -- Tim Zych http://www.higherdata.com "Tim Zych" <feedback at higherdata dt com wrote in message ... This worked for me. ' In a regular module Public gX As Single, gY As Single ' In a userform Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) gX = X gY = Y Debug.Print CStr("Does " & CStr(X) & " = " & CStr(gX) & "?") Debug.Print CStr("Does " & CStr(Y) & " = " & CStr(gY) & "?") End Sub -- Tim Zych http://www.higherdata.com "Roger" wrote in message ... I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
Thanks for the 2 suggestions - I'll give them a try
-- Roger "Roger" wrote: I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
They work - thanks a lot - I am impressed
-- Roger "Roger" wrote: Thanks for the 2 suggestions - I'll give them a try -- Roger "Roger" wrote: I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mouse Move Event
I have implemented your solution with great effect - I have reduced the
amount of code required considerably - thankyou for your help -- Roger "Gary''s Student" wrote: Declare Function GetCursorPos Lib "user32" _ (lpPoint As POINTAPI) As Long Type POINTAPI x As Long y As Long End Type Sub ShowPos() Dim lRetVal As Long Dim Pos As POINTAPI lRetVal = GetCursorPos(Pos) MsgBox Pos.x & ", " & Pos.y End Sub This will retrieve and display the coordinates. -- Gary''s Student - gsnu200834 "Roger" wrote: I use the X & Y values in the mouse move event to make a comments box follow the mouse pointer - how can I pass the X & Y values to a different sub - I have declared them as public to no avail - they only work when they are used in the actual mouse move routine I could reduce the amount of code I am using by a significant amount if this is possible - thanks in anticipation -- Roger |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trap Mouse Move event for Images inside the shape or Image control | Excel Programming | |||
mouse over event | Excel Discussion (Misc queries) | |||
mouse move event | Excel Programming | |||
mouse move and exit event | Excel Programming | |||
Activate / Deactivate mouse move event | Excel Programming |