How to Use Animated Cursors
Posted on January 5, 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 | 'System & API - How to Use Animated Cursors Option Explicit 'Add two Command Buttons to your form. The first one is to load the Animated Cursor 'The second one to unload the cursor. 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 Dim lResult As Long Dim mhAniCursor As Long Dim mhAniCursor2 As Long Private Sub Command1_Click() 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 |