CodeItBetter Programming Another VB Programming Blog

How to Show/Hide/Restore Mouse Cursor

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'System & API - How to Show/Hide/Restore Mouse Cursor
Option Explicit
 
' Mouse/cursor functions.
Private lShowCursor As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
 
' Hides the mouse cursor.
Public Sub HideMouse()
    Dim iResult As Integer
    Do
        lShowCursor = lShowCursor - 1
        iResult = ShowCursor(False)
    Loop Until iResult < 0
End Sub
 
' Restores the mouse cursor to it's previous state regardless if HideMouse and ShowMouse were called.
Public Sub RestoreMouse()
    If lShowCursor > 0 Then
        Do While lShowCursor <> 0
            ShowCursor (False)
            lShowCursor = lShowCursor - 1
        Loop
    ElseIf lShowCursor < 0 Then
        Do While lShowCursor <> 0
            ShowCursor (True)
            lShowCursor = lShowCursor + 1
        Loop
    End If
End Sub
 
'  Show's the mouse cursor.
Public Sub ShowMouse()
    Dim iResult As Integer
    Do
        lShowCursor = lShowCursor - 1
        iResult = ShowCursor(True)
    Loop Until iResult >= 0
End Sub

Related posts:

  1. How to Set Mouse Cursor position
  2. How to create a screen saver.
  3. How to show/hide the cursor/caret in a text box
  4. How to show Accessability Properties (Mouse)
  5. How to show Mouse Properties Control Panel
  6. How to Move the Cursor to the Control that has focus
  7. How to Show/Hide all Desktop Icons
  8. How to Limit Cursor Movement to Form Boundaries
  9. How to Show/Hide your SystemTray
  10. How to Show/Hide the Start Button from the task bar

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.