Solved

Animated cursor

Posted on 2004-04-02
6
1,192 Views
Last Modified: 2013-11-19
Hello Experts.
I am using VB6.
I would like to make the mouse pointer animated and/or make an animated picture on a form.
I know how to do it in Windows,but I would like to do it in the program when I want it.
Is there a way to do it ?
Thanks
0
Comment
Question by:HESUS
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:Tommy Kinard
Comment Utility
Hi HESUS,

The code below will show and animated mouse pointer. This one is loaded from a file on the hard drive.

Private Sub CmdAnimateCursor()
    Dim filename As String
    filename = "C:\directory" & "\animatedfile.ani"
    new_cursor = LoadCursorFromFile(filename)
    old_cursor = GetCursor()
    old_cursor = CopyCursor(old_cursor)
    SetSystemCursor new_cursor, OCR_NORMAL
End Sub

Private Sub CmdNormalCursor()
    SetSystemCursor old_cursor, OCR_NORMAL
    old_cursor = 0
End Sub
Private Sub Form_Load()
    SetSystemCursor 0, OCR_NORMAL
End Sub

HTH
dragontooth

0
 
LVL 1

Expert Comment

by:NO_CARRIER
Comment Utility
it depends.. when do you want the cursor to animate?.. all the time?.. when loading?... on hover?
0
 

Author Comment

by:HESUS
Comment Utility
To dragontooth.
I tried the code you sent me,and I get the following error message:
"Can't find DLL entry point CopyCursor in user32".
I am using VB6 and I tried to copy another user32 from another machine,but with no luck.
Any idea?

To NO CARRIER, I want to change the cursor in the middle of the program for a while,and then change it back to the default.

Thanks
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Accepted Solution

by:
NO_CARRIER earned 50 total points
Comment Utility
okay... this is what you need:

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)
Dim sCursorFile As String
Dim hCursor As Long
Dim hOldCursor As Long
Dim lReturn As Long

sCursorFile = "d:\winnt\cursors\globe.ani" 'load animated cursor

' Set the animated cursor
hCursor = LoadCursorFromFile(sCursorFile)
hOldCursor = SetClassLong(Form1.hwnd, GCL_HCURSOR, hCursor)

' Restore the cursor
lReturn = SetClassLong(Form1.hWnd, GCL_HCURSOR, hOldCursor)
0
 
LVL 1

Expert Comment

by:NO_CARRIER
Comment Utility
also.. if the cursor animation is while something is loading... (similar to an hourglass).. it's always a good idea to disable the user from interacting with the form.

'during animated cursor
Form1.Enabled=False

'restore default cursor
'Form1.Enabeld=True


+++ath0
NO CARRIER
0
 

Author Comment

by:HESUS
Comment Utility
To NO CARRIER many thanks.It is working.
There are two problems though:
1. If I move the cursor to one of the controls on the form,the animation disapears.If I disable the form then the animation is not working.
2.When I try to restore the default cursor,it will not restore until I move the cursor to one of the controls on the form.

Otherwise it works fine.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now