I have a slider(Slider1) and want to know the X position of the mouse, without a left or right click, when its inside the slider.
Have set Slider1 Tracking to true but the MouseMove event doesn't show anything.
Any advice would be welcome
Mouse position in slider
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Mouse position in slider
Do you just want a pixel value for the mouse when inside the slider control or some derived value that matches the slider value.
For the simple case you could run a timer to report the mouse position:-
For the simple case you could run a timer to report the mouse position:-
Public Sub Timer1_Timer()
Me.text = Mouse.ScreenX
End
...and then make corrections based upon the position of the control on the form.Public Sub Timer1_Timer()
Me.text = Mouse.ScreenX - Me.Left - Slider1.Left
If Val(Me.Text) < 0 Then
Me.Text = 0
Endif
If Val(Me.Text) > Slider1.Width Then
Me.Text = Slider1.Width
Endif
End
However, I have a feeling I'm miles away from understanding the question.- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Mouse position in slider
Have a look at the attached code, does that help? My friend Matt is thinking that there is a bug in 'tracking'.
UPDATE: - The tracking works differently from other controls. It does not track the mouse but the slider. The help file states "Indicates that the Slider emits Change events continuously when it is moved, not just the mouse button is released."
UPDATE: - The tracking works differently from other controls. It does not track the mouse but the slider. The help file states "Indicates that the Slider emits Change events continuously when it is moved, not just the mouse button is released."
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Mouse position in slider
Thanks stevedee, the slider is showing the progress of an audio file playback. I want to show the exact time value when the mouse is positioned in the slider.
Thank you cogier for the demo file, I'm having trouble extracting it.
$:tar -xzf Test2.tar.gz
returns:-
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Where am I going wrong?
Thank you cogier for the demo file, I'm having trouble extracting it.
$:tar -xzf Test2.tar.gz
returns:-
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Where am I going wrong?
Re: Mouse position in slider
That's a clever solution, somewhat hackish, but should be effective. I looked and couldn't find a better way in the Wiki.
However, I think you also want to check the Mouse.Y value so that the mouse is either on or near the slider.
Miles? I think you nailed it.
.... and carry a big stick!
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Mouse position in slider
Hi Bill, try this one.
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Mouse position in slider
Thank you so much Cogier - perfect!