Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trap Mouse Move event for Images inside the shape or Image control jd Excel Programming 1 September 25th 08 11:21 AM
mouse over event rk0909 Excel Discussion (Misc queries) 1 September 3rd 06 02:51 PM
mouse move event David Excel Programming 0 August 22nd 05 11:21 AM
mouse move and exit event Shrinu Excel Programming 0 May 27th 04 01:09 AM
Activate / Deactivate mouse move event Rolo[_3_] Excel Programming 2 January 29th 04 01:50 PM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"