Source code of Windows XP (NT5)
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.

117 lines
4.1 KiB

  1. //****************************************************************************
  2. //
  3. // Copyright (c) 1994, Microsoft Corporation
  4. //
  5. // File: BUSY.H
  6. //
  7. // The classes defined here are:
  8. //
  9. // CBusy Utility class to indicate to the user that the app is busy.
  10. // When an instance is constructed, it changes the cursor to the
  11. // wait cursor. If a parent window is provided it will receive a
  12. // message to set the text of its status indicator to a specified
  13. // string. This is useful for windows that have a status bar or
  14. // some other textual indication of status. When the instance is
  15. // destructed, the cursor is restored and the parent window is
  16. // sent a message to reset its status indicator.
  17. //
  18. // History:
  19. //
  20. // Scott V. Walker, SEA 6/30/94 Created.
  21. //
  22. //****************************************************************************
  23. #ifndef _BUSY_H_
  24. #define _BUSY_H_
  25. //****************************************************************************
  26. //
  27. // Messages sent to parent window.
  28. //
  29. //----------------------------------------------------------------------------
  30. //
  31. // WM_BUSY_GETTEXT
  32. //
  33. // This message is sent by the CBusy to retrieve the current status indicator
  34. // text. The CBusy will restore this text when it destructs.
  35. //
  36. // wparam = nLength; // Length of buffer.
  37. // lparam = (LPARAM)pStr; // Pointer to buffer to copy data into.
  38. //
  39. //----------------------------------------------------------------------------
  40. //
  41. // WM_BUSY_SETTEXT
  42. //
  43. // This message is sent by the CBusy to inform the window to set its status
  44. // indicator to the given string.
  45. //
  46. // wparam is unused.
  47. // lparam = (LPARAM)pStr; // Pointer to buffer containing status text.
  48. //
  49. // Return value = n/a.
  50. //
  51. //****************************************************************************
  52. #define WM_BUSY_GETTEXT (WM_USER + 0x75)
  53. #define WM_BUSY_SETTEXT (WM_USER + 0x76)
  54. //****************************************************************************
  55. //
  56. // CLASS: CBusy
  57. //
  58. // When you construct a CBusy, you have the option of specifying a parent
  59. // window and a string ID. If these are provided, The CBusy will send
  60. // WM_BUSY_GETTEXT and WM_BUSY_SETTEXT messages to the window during
  61. // construction and destruction. The parent window can respond to these
  62. // messages by modifying a text status indicator (such as a status bar) to
  63. // display the specified string. Use these by constructing a local instance
  64. // at the top of a function. When the function goes out of scope (no matter
  65. // where the return is encountered), the instance will be destructed, causing
  66. // the busy indications (cursor and text) to be restored.
  67. //
  68. //----------------------------------------------------------------------------
  69. //
  70. // CBusy::CBusy
  71. //
  72. // Constructor. When an instance is constructed, it sets the cursor to the
  73. // wait cursor and optionally notifies a specified window to change its
  74. // status indicator.
  75. //
  76. // Parameters:
  77. // CWnd *pParentWnd Optional parent window. If provided, the CBusy
  78. // sends WM_BUSY_GETTEXT and WM_BUSY_SETTEXT
  79. // messages to the given window.
  80. // const char *pszText Optional string. If provided (and if a parent
  81. // window is specified), the CBusy passes it in the
  82. // WM_BUSY_SETTEXT message to the parent window. If
  83. // not provided, the parent window is sent an empty
  84. // string.
  85. //
  86. // If parameter 2 is a UINT, CBusy will treat it as a string ID and do a
  87. // LoadString.
  88. //
  89. //****************************************************************************
  90. class CBusy : public CObject
  91. {
  92. private:
  93. CWnd *m_pParentWnd;
  94. HCURSOR m_hOldCursor;
  95. CString m_sOldText;
  96. private:
  97. void SetBusy(CWnd *pParentWnd, LPCTSTR pszText);
  98. public:
  99. CBusy(CWnd *pParentWnd, LPCTSTR pszText);
  100. CBusy(CWnd *pParentWnd, UINT nID);
  101. CBusy(CWnd *pParentWnd);
  102. CBusy();
  103. ~CBusy();
  104. };
  105. #endif // _BUSY_H_