Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Animated Cursor

21 views
Skip to first unread message

Tony V

unread,
Jul 16, 2001, 6:14:51 PM7/16/01
to
Is there a way to replace the regular mouse cursor with an
animated cursor?

thanks Tony

alpine

unread,
Jul 16, 2001, 9:35:06 PM7/16/01
to
On Mon, 16 Jul 2001 15:14:51 -0700, "Tony V" <nos...@hotmail.com>
wrote:

>Is there a way to replace the regular mouse cursor with an
> animated cursor?
>
>thanks Tony


Yes, but to do it properly, you need to subclass the WM_SETCURSOR
message for the window(s) for which you want the cursor displayed
over.

HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alp...@mvps.org Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas

Alick

unread,
Jul 16, 2001, 10:50:39 PM7/16/01
to
Hi Tony,

We need to call APIs to set the animated cursor. The following codes do
this:

Option Explicit
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long,
ByVal id As Long) As Long
Dim tempcurs As Long
Const OCR_NORMAL = 32512

Private Sub ChangeCursor_Click()

Dim MyDir As String
Dim currenthcurs As Long
Dim newhcurs As Long

currenthcurs = GetCursor()

tempcurs = CopyIcon(currenthcurs)

MyDir = "D:\WINNT\CURSORS\dinosaur.ani"

newhcurs = LoadCursorFromFile(MyDir)

SetSystemCursor newhcurs, OCR_NORMAL

End Sub

Private Sub RestoreCursor_Click()

SetSystemCursor tempcurs, OCR_NORMAL

End Sub

Tony V

unread,
Jul 17, 2001, 12:54:27 PM7/17/01
to
Thanks
>.
>

Klaus H. Probst

unread,
Jul 17, 2001, 11:45:52 PM7/17/01
to
Check out the samples at www.vbbox.com. There's one that loads an ANI file
from a file and uses it on a form.


--
. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
http://www.vbbox.com/


Please post/reply to the newsgroup(s)


"Tony V" <nos...@hotmail.com> wrote in message
news:697301c10e44$bbd7eda0$9ae62ecf@tkmsftngxa02...

Gang

unread,
Jul 18, 2001, 3:54:11 AM7/18/01
to
Try the below code


Private Const OCR_NORMAL = 32512&

Private Declare Function LoadCursor Lib "user32" Alias _
"LoadCursorA" (ByVal hInstance As Long, ByVal _
lpCursorName As Long) As Long

Private Declare Function LoadCursorFromFile Lib _
"user32" Alias "LoadCursorFromFileA" (ByVal lpFileName _
As String) As Long

Private Declare Function SetSystemCursor Lib "user32" _
(ByVal hcur As Long, ByVal id As Long) As Boolean

Private Sub Form_Load()
Dim hcursor As Long, ret_val As Long
hcursor = LoadCursorFromFile("c:\appstart.ani")
ret_val = SetSystemCursor(hcursor, OCR_NORMAL)
End Sub

0 new messages