VB icon

Animate your program cursor

Email
Submitted on: 1/17/2015 6:30:00 PM
By: Anonymous (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: VB 5.0, VB 6.0
Views: 539
 
     This little snippet will make the cursor animated. I.E a globe that is spinning.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Animate your program cursor
'**************************************
'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)
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Animate your program cursor
' Description:This little snippet will make the cursor animated. I.E a globe that is spinning.
' By: Anonymous (from psc cd)
'
' 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.
'**************************************

'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)


Other 209 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.