VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Animate your program cursor


Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This little snippet will make the cursor animated. I.E a globe that is spinning.

Assumes
Be sure to know that the cursor you are gona use is a Animated cursor, if you don't got one you can probably find one at a windows desktop theme site.
Side Effects
Not as far as I know.
API Declarations
'This part will go into a module
'Its only 2 functions and 1 constant 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
Public Const GCL_HCURSOR = (-12)

Rate Animate your program cursor

'put this in your Form_Load event or in whatever you would like to trigger the code.
'Note be sure that the cursor you want to use is a Animated cursor.
Dim sCursorFile As String
Dim hCursor As Long
Dim hOldCursor As Long
Dim lReturn As Long
'Pointing to the place where to cursor is.
sCursorFile = App.Path & "\animantedcursor.ani"
hCursor = LoadCursorFromFile(sCursorFile)
'Change the Form1.hwnd to yourformname.hwnd
hOldCursor = SetClassLong(Form1.hwnd, GCL_HCURSOR, hCursor)
'Use this to get back to normal cursor again.
'you can trigger it on form unload event or whatever you want to use to end it.
lReturn = SetClassLong(Form1.hWnd, GCL_HCURSOR, hOldCursor)

Download this snippet    Add to My Saved Code

Animate your program cursor Comments

No comments have been posted about Animate your program cursor. Why not be the first to post a comment about Animate your program cursor.

Post your comment

Subject:
Message:
0/1000 characters