Hello All,
I'm new to programming and this forum so please excuse me if this is a stupid question.
I'm trying to resize a form when the mouse is 'tapped' twice against the edge of the screen. My idea is to use the mouse move event to start a timer when the mouse co-ordinates are equal to that of the screen edge. If the timer is already running then it stops the timer and resizes the form. The timer runs for .5 seconds and then disables itself so that the taps have to be close enough to be consider deliberate. The code for these events are listed below.
The problem with this is that the mouse move event is only fired when the mouse is over the form. How can I get the mouse move event to fire even if it's not over the form? Or is there a better way to approach this problem? (This solution seems fairly process intesive as the mouse move event is constantly therefore running the sub all the time.)
Any help is greatly appreicated.
Cheers
Ben
I'm new to programming and this forum so please excuse me if this is a stupid question.
I'm trying to resize a form when the mouse is 'tapped' twice against the edge of the screen. My idea is to use the mouse move event to start a timer when the mouse co-ordinates are equal to that of the screen edge. If the timer is already running then it stops the timer and resizes the form. The timer runs for .5 seconds and then disables itself so that the taps have to be close enough to be consider deliberate. The code for these events are listed below.
VB.NET:
Dim ScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width - 1
Dim ScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim cX As Integer = Cursor.Position.X
Dim cY As Integer = Cursor.Position.Y
Dim TapSensitivity As Integer = 30
If (cX = 0) Then
'if at screen edge...
If Not ScreenTapTimer.Enabled Then
ScreenTapTimer.Enabled = True
MovedAway = False
Else
If MovedAway Then
ScreenTapTimer.Enabled = False
'things to do when screen is tapped
If Me.WindowState = FormWindowState.Maximized Then
Me.WindowState = FormWindowState.Normal
Else
Me.WindowState = FormWindowState.Maximized
End If
End If
End If
Else
'if not at the screen edge.....
If ((cX > TapSensitivity)) And ScreenTapTimer.Enabled Then
MovedAway = True
End If
End If
End Sub
Private Sub ScreenTapTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScreenTapTimer.Tick
ScreenTapTimer.Enabled = False
End Sub
End Class
Any help is greatly appreicated.
Cheers
Ben
Last edited: