devxlogo

Show an Hourglass When Processing Data

Show an Hourglass When Processing Data

Have you ever forgotten to add code to set the MousePointer back to its default at the end of a procedureor function? This technique simplifies showing and resetting the MousePointer without adding code to theend of a procedure or function.When you create an object from a class, the Initialize event is generated. Any code in the event procedurefor that event then executes. This is the first code to execute for the object, before you set any properties orinvoke any methods. When the variable goes out of scope, all references to the object are released, theTerminate event is generated for the object, and any code in the Terminate event procedure for that object isexecuted:

 Declare Sub Sleep Lib "kernel32" _        (ByVal dwMilliseconds As Long)' this is an example of a procedure that' uses the CHourGlass classPrivate Sub ProcessData()        Dim MyHourGlass As CHourGlass        Set MyHourGlass = New CHourGlass        'Add processing code here        Sleep 5000 'This simulates the         'processing of data        'Resume processing code hereEnd Sub'Create a CHourGlass class with the 'following code:Private Sub Class_Initialize()        'Show HourGlass        Screen.MousePointer = vbHourglassEnd SubPrivate Sub Class_Terminate()        'Restore MousePointer        Screen.MousePointer = vbDefaultEnd Sub
See also  Redefining Energy Management: Advanced Solutions for Modern Buildings
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist