# ShowCursor Function

`Declare Function ShowCursor Lib "user32.dll" (ByVal bShow As Long) As Long`

ShowCursor either shows or hides the mouse cursor. This is not done directly, but rather by incrementing or decrementing a counter. Each function call raises or lowers the counter by 1. If the counter is negative, the cursor is invisible. It if it non-negative, the cursor is visible. The function returns the value of the counter after changing it.

bShow
  If zero, decrements the counter by 1. If non-zero, increments the counter by 1.

Example:

    ' Hide the cursor
    Do
      x = ShowCursor(0)  ' decrement by 1
    Loop Until x < 0  ' continue until cursor is hidden
    ' Show the cursor
    Do
      x = ShowCursor(1)  ' increment by 1
    Loop Until x >= 0  ' continue until cursor is visible

Category: Mouse
Back to the index.