Solved

Changing Hourglass to Animated one

Posted on 1998-08-14
1
1,733 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 55
bit defender blocks good applications 2 94
Using "ScreenUpdating" 6 65
Add a task in Outlook from access 11 39
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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