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
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.