Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay an animated mouse cursor
Keywordsanimated, cursor, ani
CategoriesTips and Tricks, Multimedia, Graphics
 
Thanks to Alexander Willemse P> Use the CopyCursor, LoadCursorFromFile, GetCursor, and SetSystemCursor API functions. Use LoadCursorFromFile to load a .ani file containing the animated cursor.

Note: The example program sets the cursor back to normal in its Form_Unload event handler. You should be sure you set it back to normal before your programs end, too.

 
Private Sub CmdAnimateCursor_Click()
    Dim filename As String
    filename = App.Path + "\glas.ani"
    new_cursor = LoadCursorFromFile(filename)
    old_cursor = GetCursor()
    old_cursor = CopyCursor(old_cursor)
    SetSystemCursor new_cursor, OCR_NORMAL

    CmdAnimateCursor.Enabled = False
    CmdNormalCursor.Enabled = True
End Sub

Private Sub CmdNormalCursor_Click()
    SetSystemCursor old_cursor, OCR_NORMAL

    CmdAnimateCursor.Enabled = True
    CmdNormalCursor.Enabled = False

    old_cursor = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If old_cursor <> 0 Then SetSystemCursor old_cursor, _
        OCR_NORMAL
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated