Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Aug 1, 1997

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 procedure or function? This technique simplifies showing and resetting the MousePointer without adding code to the end of a procedure or function. When you create an object from a class, the Initialize event is generated. Any code in the event procedure for that event then executes. This is the first code to execute for the object, before you set any properties or invoke any methods. When the variable goes out of scope, all references to the object are released, the Terminate event is generated for the object, and any code in the Terminate event procedure for that object is executed:
 
Declare Sub Sleep Lib "kernel32" _
        (ByVal dwMilliseconds As Long)

' this is an example of a procedure that
' uses the CHourGlass class
Private 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 here
End Sub

'Create a CHourGlass class with the 
'following code:
Private Sub Class_Initialize()
        'Show HourGlass
        Screen.MousePointer = vbHourglass
End Sub

Private Sub Class_Terminate()
        'Restore MousePointer
        Screen.MousePointer = vbDefault
End Sub
Kurt D.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date