Solved

Animated cursor

Posted on 2004-04-02
6
1,235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 10741009
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
ID: 10745702
it depends.. when do you want the cursor to animate?.. all the time?.. when loading?... on hover?
0
 

Author Comment

by:HESUS
ID: 10791461
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
NO_CARRIER earned 50 total points
ID: 10804828
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
ID: 10804836
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
ID: 10857606
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 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