How to know if the mouse action is still on click?
I'm about to do a click and hold function. A timer will start when mouse is click on certain position. And when the timer is tick, I want to detect is the mouse is still click then I do run my other code.
This is how I made the code just like your tap + hold on smartphone.
Dim point1, point2 As Point
Dim WithEvents tmrhold As New DispatcherTimer
When button.Click or rectangle.MouseDown, I start the timer and locate the first mouse position.
tmrhold.Interval = TimeSpan.FromMilliseconds(1000)
point1 = Me.PointToScreen(Mouse.GetPosition(Me))
When timer tick, I check again the current position and compare it with first position. And I make sure the mouse is on click. If I don't do that, when I click and leave the mouse on the same position, it has the same position but not as same action (user still on click). So check if user still on click and position is same.
Private Sub tmrhold_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrhold.Tick
If Mouse.LeftButton = MouseAction.LeftClick Then
point2 = Me.PointToScreen(Mouse.GetPosition(Me))
If point2 = point1 Then