Solved

Animated cursor

Posted on 2004-04-02
6
1,244 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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 receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

729 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