'----------------------------------------------------------------------
' DESCRIPTION: Class Module clshourglassXL
'-------------
'This class not only provides the SetCursor method, which provides a
' convenient method of setting the hourglass cursor, but it automatically
' restores the cursor when the class object is destroyed.
'
'Although you can call the Restore method to restore the cursor, it is not
' necessary. Using clsHourglassXL guarantees the cursor will be restored
' when the subroutine terminates, even if the subroutine terminates due
' to an unhandled run-time error!
'----------------------------------------------------------------------
' HISTORY:
'---------
' Adapted from Access VBA
'----------------------------------------------------------------------
' INPUT:
'-------
' cCursor.setCursor
' OR
' cCursor.Restore
'----------------------------------------------------------------------
' OUTPUT:
'--------
' Changes the cursor hourglass
'----------------------------------------------------------------------
' SAMPLE CALL:
'-------------
'Declare your clsHourglassXL object within a subroutine:
'
'Sub Eyeglass()
' Dim cCursor As New clsHourGlassXL
' cCursor.SetCursor
'Stop
' cCursor.Beam
'Stop
' cCursor.Arrow
'Stop
' 'Perform lengthy tasks here
' cCursor.Restore
' End Sub
'----------------------------------------------------------------------'DECLARATIONS:
'-------------
Option Explicit
#Const DEBUG_ = False ' Set to False for Release version or True for Development
Private Const C_MODULE_NAME = "clsHourGlassXL"
Private mintOldPointer As Integer ' Save Current Pointer State
Private Sub Class_Initialize()
On Error Resume Next
' Save current mouse pointer
mintOldPointer = Application.Cursor
' Change to hourglass
Application.Cursor = xlWait 'vbHourGlass
End Sub
Private Sub Class_Terminate()
Const C_PROC_NAME = "Class_Terminate"
Restore
End Sub
Public Sub SetCursor()
Const C_PROC_NAME = "SetCursor"
' Set mouse pointer to hourglass/wait state.
Application.Cursor = xlWait
End Sub
Public Sub Restore()
Const C_PROC_NAME = "Restore"
' Return mouse pointer to normal display.
Application.Cursor = xlDefault
End Sub
Public Sub Beam()
Const C_PROC_NAME = "Beam"
' Set mouse pointer to IBeam display.
Application.Cursor = xlIBeam
End Sub
Public Sub Arrow()
Const C_PROC_NAME = "Arrow"
' Set mouse pointer to NorthWestArrow display.
Application.Cursor = xlNorthwestArrow
End Sub