Solved

Changing Hourglass to Animated one

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

707 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

15 Experts available now in Live!

Get 1:1 Help Now