Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. CnclTask.hxx
  7. This file contains the class definition for the Task Cancel dialog.
  8. FILE HISTORY:
  9. Johnl 20-Oct-1992 Created
  10. */
  11. #ifndef _CNCLTASK_HXX_
  12. #define _CNCLTASK_HXX_
  13. #include "applibrc.h"
  14. #define SLT_STATUS_TEXT 200
  15. #define CANCEL_TASK_DIALOG_NAME (MAKEINTRESOURCE( IDD_CANCEL_TASK ))
  16. #ifndef RC_INVOKED
  17. #include "ellipsis.hxx"
  18. #define CANCEL_TASK_TIMER_ID (0xBEEF)
  19. #define CANCEL_TASK_TIMER_INTERVAL (10)
  20. /*************************************************************************
  21. NAME: CANCEL_TASK_DIALOG
  22. SYNOPSIS: This dialog presents a simple dialog with a status text line
  23. and a cancel button. At regular (short) intervals, a
  24. virtual callout will be called.
  25. INTERFACE:
  26. DoOneItem
  27. Redefine this method for the intervaled callout
  28. If an error is returned, the user will be notified using the
  29. message passed into the constructor with the inserted error
  30. string and the object name that was last put in the status
  31. field.
  32. UpdateStatus
  33. Sets the status text of the dialog. Should be set at the
  34. beginning of each task (i.e., callout from DoOneItem).
  35. PARENT: DIALOG_WINDOW
  36. USES:
  37. CAVEATS:
  38. NOTES: Message format for displaying errors returned by DoOneItem.
  39. %1 should be the error message text, %2 will be the object text
  40. (%2 is optional).
  41. By default, the object name will be what's in the status SLT.
  42. HISTORY:
  43. Johnl 21-Oct-1992 Created
  44. **************************************************************************/
  45. DLL_CLASS CANCEL_TASK_DIALOG : public DIALOG_WINDOW
  46. {
  47. public:
  48. CANCEL_TASK_DIALOG( UINT idDialog,
  49. HWND hwndParent,
  50. const TCHAR * pszDlgTitle,
  51. ULONG_PTR ulContext,
  52. MSGID msgidErrorMsg,
  53. ELLIPSIS_STYLE style = ELLIPSIS_PATH ) ;
  54. ~CANCEL_TASK_DIALOG() ;
  55. APIERR UpdateStatus( const TCHAR * pszStatusText )
  56. { return _sltStatusText.SetText( pszStatusText ) ; }
  57. protected:
  58. //
  59. // The callout is called until *pfContinue is set to FALSE. Errors can
  60. // be reported simply by returning the error and setting *pfDisplayError
  61. // to TRUE.
  62. //
  63. // To display an alternate message, set *pmsgidAlternateError
  64. // It must have %1 (object name) and %2 (error).
  65. //
  66. virtual APIERR DoOneItem( ULONG_PTR ulContext,
  67. BOOL * pfContinue,
  68. BOOL * pfDisplayError,
  69. MSGID * pmsgidAlternateError ) ;
  70. virtual BOOL OnTimer( const TIMER_EVENT & e ) ;
  71. //
  72. // If we failed to construct the timer, then we will loop here calling
  73. // OnTimer (i.e., simulating time slices w/o relinquishing control).
  74. // We do it here rather then the constructor because derived vtables
  75. // aren't setup at construct time.
  76. //
  77. virtual BOOL MayRun( void ) ;
  78. //
  79. // The object name to be used for error messages returned by DoOneItem
  80. // Defaults to the text in the status SLT
  81. //
  82. virtual APIERR QueryObjectName( NLS_STR *pnlsObjName ) ;
  83. BOOL IsFinished( void ) const
  84. { return _fDone ; }
  85. void SetInTimer( BOOL fInTimer )
  86. { _fInTimer = fInTimer ; }
  87. BOOL IsInTimer( void ) const
  88. { return _fInTimer ; }
  89. private:
  90. //
  91. // Where ellipsized status messages are output
  92. //
  93. SLT_ELLIPSIS _sltStatusText ;
  94. //
  95. // The client's general purpose context
  96. //
  97. ULONG_PTR _ulContext ;
  98. MSGID _msgidErrorMsg ;
  99. UINT_PTR _idTimer ;
  100. //
  101. // Semaphore type flag so we don't re-enter the OnTimer method when
  102. // we are waiting for user input after an error message.
  103. // This allows us to not kill the timer every time we do an item.
  104. //
  105. BOOL _fInTimer ;
  106. //
  107. // Set to TRUE after DoOneItem indicates we're done.
  108. //
  109. BOOL _fDone ;
  110. } ;
  111. #endif //RC_INVOKED
  112. #endif //_CNCLTASK_HXX_