home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD7555792000.psc / VBRecentProjects / clsWaitCurs.cls < prev    next >
Encoding:
Visual Basic class definition  |  1998-12-18  |  1.6 KB  |  58 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsWaitCursor"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14.  
  15. Option Explicit
  16.  
  17. 'WaitCursor - Wait cursor class demo
  18. '
  19. 'This Visual Basic 5.0 example program demonstrates how you can use
  20. 'a simple class to help you set an hourglass cursor. This class not
  21. 'only provides the SetCursor method, which provides a convenient
  22. 'method of setting the hourglass cursor (or a custom cursor if you
  23. 'like), but it automatically restores the previous cursor when the
  24. 'class object is destroyed.
  25. '
  26. 'Declare your CWaitCursor object within a subroutine:
  27. '
  28. ' Private Sub MySub()
  29. '     Dim wait As New CWaitCursor
  30. '     wait.SetCursor
  31. '
  32. '     'Perform lengthy tasks here
  33. '
  34. ' End Sub
  35. '
  36. 'Although you can call the Restore method to restore the previous
  37. 'cursor, it is not necessary. CWaitCursor guarantees that the cursor
  38. 'will be restored when the subroutine terminates, even if the
  39. 'subroutine terminates due to an unhandled run-time error!
  40.  
  41. Private m_nPointer As MousePointerConstants
  42.  
  43. Public Sub SetCursor(Optional nPointer As MousePointerConstants = vbHourglass)
  44.  Screen.MousePointer = nPointer
  45. End Sub
  46.  
  47. Public Sub Restore()
  48.  Screen.MousePointer = m_nPointer
  49. End Sub
  50.  
  51. Private Sub Class_Initialize()
  52.  m_nPointer = Screen.MousePointer
  53. End Sub
  54.  
  55. Private Sub Class_Terminate()
  56.  Restore
  57. End Sub
  58.