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.

120 lines
2.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. busydlg.h
  7. base class for the busy dialog
  8. FILE HISTORY:
  9. */
  10. #ifndef _BUSYDLG_H
  11. #define _BUSYDLG_H
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CWorkerThread
  14. class CWorkerThread : public CWinThread
  15. {
  16. public:
  17. CWorkerThread();
  18. virtual ~CWorkerThread();
  19. BOOL Start(HWND hWnd);
  20. virtual BOOL InitInstance() { return TRUE; } // MFC override
  21. virtual int Run() { return -1;} // MFC override
  22. void Lock() { ::EnterCriticalSection(&m_cs); }
  23. void Unlock() { ::LeaveCriticalSection(&m_cs); }
  24. void Abandon();
  25. BOOL IsAbandoned();
  26. void AcknowledgeExiting() { VERIFY(0 != ::SetEvent(m_hEventHandle));}
  27. protected:
  28. virtual void OnAbandon() {}
  29. protected:
  30. BOOL PostMessageToWnd(UINT Msg, WPARAM wParam, LPARAM lParam);
  31. void WaitForExitAcknowledge();
  32. private:
  33. CRITICAL_SECTION m_cs;
  34. HANDLE m_hEventHandle;
  35. HWND m_hWnd;
  36. BOOL m_bAbandoned;
  37. };
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDlgWorkerThread
  40. class CLongOperationDialog; // fwd decl
  41. class CDlgWorkerThread : public CWorkerThread
  42. {
  43. public:
  44. CDlgWorkerThread();
  45. BOOL Start(CLongOperationDialog* pDlg);
  46. virtual int Run(); // MFC override
  47. DWORD GetError() { return m_dwErr;}
  48. protected:
  49. virtual void OnDoAction() = 0;
  50. DWORD m_dwErr;
  51. private:
  52. BOOL PostMessageToDlg();
  53. };
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CLongOperationDialog dialog
  56. class CLongOperationDialog : public CDialog
  57. {
  58. // Construction
  59. public:
  60. static UINT s_nNotificationMessage;
  61. CLongOperationDialog(CDlgWorkerThread* pThreadObj, UINT nAviID = -1);
  62. virtual ~CLongOperationDialog();
  63. BOOL LoadTitleString(UINT nID);
  64. BOOL LoadDescriptionString(UINT nID);
  65. void EnableCancel(BOOL bCancel) { m_bCancel = bCancel; }
  66. CDlgWorkerThread* GetThreadObj()
  67. {
  68. ASSERT(m_pThreadObj != NULL);
  69. return m_pThreadObj;
  70. }
  71. UINT m_nAviID;
  72. CString m_strTitle;
  73. CString m_strDescription;
  74. BOOL m_bAbandoned;
  75. afx_msg LONG OnNotificationMessage( WPARAM wParam, LPARAM lParam);
  76. // Implementation
  77. protected:
  78. // Generated message map functions
  79. virtual BOOL OnInitDialog();
  80. virtual void OnCancel();
  81. DECLARE_MESSAGE_MAP()
  82. private:
  83. CDlgWorkerThread* m_pThreadObj;
  84. BOOL m_bCancel;
  85. };
  86. #endif _BUSYDLG_H