• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Animated cursors...

VB alows us to change cursor for example into hourglass when longer task performs. I noticed that it doesn't support animated cursos... smahe. Does anyone of you know how could I simply change cursor to animated one when longer task starts?

1 Solution
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 28/06/99
' * Time             : 13:19
' **********************************************************************
' * Comments         : Using animated cursors
' *
' *
' **********************************************************************

Option Explicit
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

Private Sub Command1_Click()
   Dim lResult As Long
   Dim mhAniCursor As Long
   Dim mhAniCursor2 As Long
   mhAniCursor = LoadCursorFromFile("C:\windows\cursors\globe.ani")
   lResult = SetClassLong((hwnd), GCL_HCURSOR, mhAniCursor)
   state = 1
   mhAniCursor2 = LoadCursorFromFile("C:\windows\cursors\hourglas.ani")
   lResult = SetClassLong((Text1.hwnd), GCL_HCURSOR, mhAniCursor2)
   state = 1
End Sub

Private Sub Command2_Click()
   Dim lResult As Long
   lResult = SetClassLong((hwnd), GCL_HCURSOR, mhBaseCursor)
   lResult = DestroyCursor(mhAniCursor)
   lResult = SetClassLong((Text1.hwnd), GCL_HCURSOR, mhBaseCursor2)
   lResult = DestroyCursor(mhAniCursor2)
   state = 0
End Sub

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

Visual Basic supportes only a valid graphics file.
(i.e. bitmap, icon, Windows metafile ...) to the Picture property of a form or control.

So maybe you can, but only with a 3rd party - I guess...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now