Solved

Changing Hourglass to Animated one

Posted on 1998-08-14
1
1,726 Views
Last Modified: 2010-05-18
I know that i can replace the pointer with an .ani file of an animated hourglass instead of the typical hourglass that represents "waiting" but is there  a way to tell my entire vb app to show this animated hourglass whenever it is about to use the ordinary hourglass ie. when i call the commondialog's open box it displays the w95 predefined hourglass (as set in the Control Panel's mouse options).  I want to make sure that ALL of these hourglasses are the animated one instead.  How would i go about doing this without making repeated calls seen below throughout my program:

form.mousepointer = 99 'i believe this is the user defined type
form.mouseicon = LoadIcon("Ani-HourGlass.ani") 'i think it is loadicon

'code that i want to display with the animated hourglass goes here

form.mousepointer=0 'turn off animated hourglass and display default pointer
0
Comment
Question by:ratboy2
1 Comment
 
LVL 1

Accepted Solution

by:
DennisH earned 200 total points
ID: 1468866
Try This,

Put these declarations in a standard module.

'WinAPI32 call
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

'WinAPI32 constant
Public Const GCL_HCURSOR = (-12)

'Two global variables to hold the cursors
Global hCursor as long
Global hOldCursor as long


To create the animated cursor (in your startup form module):

Private Sub SetAniCursor(strPath as string)
   
    hCursor = LoadCursorFromFile(ByVal strPath)
    hOldCursor = SetClassLong(Me.hwnd, GCL_HCURSOR, hCursor)

End Sub

To restore the old cursor when you are done

Private Sub ResetAniCursor()

    hCursor = SetClassLong(Me.hwnd, GCL_HCURSOR, hOldCursor)

End Sub

Another approach might be to use the WinAPI32 call "CreateCursor" to create a cursor that has application-wide scope.  See the Win32 SDK for more information.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

930 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

13 Experts available now in Live!

Get 1:1 Help Now