Make your own free website on Tripod.com

Use Animated Cursors

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 Command Buttons to your form.
'Press the first button to load the animated Cursor (move the cursor from the button to the
'form area to refresh the cursor).
'Press the second button to unload the cursor.
'Insert this code to the module :

Public Const GCL_HCURSOR = -12
Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Any) As Long
Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal _
hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal _
hwnd As Long, ByVal nIndex As Long) As Long

'Insert this code to your form:

Dim lResult As Long
Dim mhAniCursor As Long
Dim mhAniCursor2 As Long
Private Sub Command1_Click()
'Replace 'C:\windows\cursors\hourglas.ani' with your ANI Cursor
mhAniCursor = LoadCursorFromFile("C:\windows\cursors\hourglas.ani")
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhAniCursor)
End Sub

Private Sub Command2_Click()
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhBaseCursor)
lResult = DestroyCursor(mhAniCursor)
End Sub

Private Sub Form_Load()
mhBaseCursor = GetClassLong((hwnd), GCL_HCURSOR)
End Sub

Private Sub Form_Unload(Cancel As Integer)
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhBaseCursor)
lResult = DestroyCursor(mhAniCursor)
End Sub

Go Back