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.

153 lines
5.0 KiB

  1. // StatsDlg.h : Declaration of the CStatusDlg
  2. #ifndef __STATUSDLG_H_
  3. #define __STATUSDLG_H_
  4. #include "resource.h" // main symbols
  5. #include <map>
  6. #include <limits.h>
  7. #include <commctrl.h>
  8. #include <atlctrls.h>
  9. #include "StatusProgress.h"
  10. #include "ProgList.h"
  11. typedef std::map<long, BSTR, std::less<long> > COMPONENTMAP;
  12. #define SD_TIMER_ID 333
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CStatusDlg
  15. class ATL_NO_VTABLE CStatusDlg :
  16. public CDialogImpl<CStatusDlg>,
  17. public CComObjectRootEx<CComSingleThreadModel>,
  18. public CComCoClass<CStatusDlg, &CLSID_StatusDlg>,
  19. public IDispatchImpl<IStatusDlg, &IID_IStatusDlg, &LIBID_WIZCHAINLib>
  20. {
  21. public:
  22. enum { IDD = IDD_STATUSDIALOG };
  23. LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&);
  24. LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  25. LRESULT OnCancelCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  26. LRESULT OnDrawItem( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  27. LRESULT OnMeasureItem( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  28. LRESULT OnClose( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  29. LRESULT OnTimerProgress( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  30. LRESULT OnUpdateOverallProgress( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  31. LRESULT OnStartTimer( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  32. LRESULT OnKillTimer( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
  33. CStatusDlg() :
  34. m_hThread(NULL),
  35. m_lFlags(LONG_MAX),
  36. m_iCancelled(0),
  37. m_pComponentProgress(NULL),
  38. m_pOverallProgress(NULL),
  39. m_strWindowTitle(_T("")),
  40. m_strWindowText(_T("")),
  41. m_lTotalProgress(0),
  42. m_lTimer(0),
  43. m_lMaxSteps(0)
  44. {
  45. m_hDisplayedEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
  46. m_pProgressList = new CProgressList;
  47. m_mapComponents.clear();
  48. }
  49. ~CStatusDlg()
  50. {
  51. if (m_hDisplayedEvent)
  52. CloseHandle(m_hDisplayedEvent);
  53. if (m_hThread)
  54. CloseHandle(m_hThread);
  55. if (m_pProgressList)
  56. delete m_pProgressList;
  57. if (m_pComponentProgress)
  58. {
  59. m_pComponentProgress->Release();
  60. }
  61. if (m_pOverallProgress)
  62. {
  63. m_pOverallProgress->Release();
  64. }
  65. COMPONENTMAP::iterator compIterator = m_mapComponents.begin();
  66. while (compIterator != m_mapComponents.end())
  67. {
  68. ::SysFreeString(compIterator->second);
  69. compIterator++;
  70. }
  71. }
  72. BEGIN_MSG_MAP(CStatusDlg)
  73. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  74. COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
  75. COMMAND_ID_HANDLER(IDCANCEL, OnCancelCmd)
  76. MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
  77. MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
  78. MESSAGE_HANDLER(WM_CLOSE, OnClose)
  79. MESSAGE_HANDLER(WM_UPDATEOVERALLPROGRESS, OnUpdateOverallProgress)
  80. MESSAGE_HANDLER(WM_TIMER, OnTimerProgress)
  81. MESSAGE_HANDLER(WM_STARTTIMER, OnStartTimer)
  82. MESSAGE_HANDLER(WM_KILLTIMER, OnKillTimer)
  83. END_MSG_MAP()
  84. DECLARE_REGISTRY_RESOURCEID(IDR_STATUSDLG)
  85. DECLARE_PROTECT_FINAL_CONSTRUCT()
  86. BEGIN_COM_MAP(CStatusDlg)
  87. COM_INTERFACE_ENTRY(IStatusDlg)
  88. COM_INTERFACE_ENTRY(IDispatch)
  89. END_COM_MAP()
  90. //CStatusDlg
  91. public:
  92. STDMETHOD(DisplayError) ( BSTR bstrError, BSTR bstrTitle, DWORD dwFlags, long* pRet );
  93. STDMETHOD(SetStatusText) ( BSTR bstrText );
  94. STDMETHOD(get_OverallProgress) ( /*[out, retval]*/ IStatusProgress* *pVal );
  95. STDMETHOD(AddComponent) ( BSTR bstrComponent, long * lIndex );
  96. STDMETHOD(Initialize) ( BSTR bstrWindowTitle, BSTR bstrWindowText, VARIANT varFlags );
  97. STDMETHOD(SetStatus) ( long lIndex, SD_STATUS lStatus );
  98. STDMETHOD(Display) ( BOOL vb );
  99. STDMETHOD(WaitForUser) ( );
  100. STDMETHOD(get_Cancelled) ( BOOL *pVal );
  101. STDMETHOD(get_ComponentProgress)( IStatusProgress * *pVal );
  102. private:
  103. BOOL AreAllComponentsDone( BOOL& bFailed );
  104. BOOL VerticalResizeWindow( HWND hWnd, int iResize );
  105. BOOL ReplaceWindow ( HWND hWndOld, HWND hWndNew );
  106. BOOL VerticalMoveWindow ( HWND hWnd, int iResize );
  107. int GetWindowLength ( HWND hWndTop, HWND hWndBottom );
  108. void SetupButtons ( );
  109. volatile int m_iCancelled;
  110. HANDLE m_hThread;
  111. TSTRING m_strWindowTitle;
  112. TSTRING m_strWindowText;
  113. long m_lFlags;
  114. HANDLE m_hDisplayedEvent;
  115. CComObject<CStatusProgress>* m_pComponentProgress;
  116. CComObject<CStatusProgress>* m_pOverallProgress;
  117. COMPONENTMAP m_mapComponents;
  118. CProgressList * m_pProgressList;
  119. volatile long m_lTotalProgress;
  120. long m_lTimer;
  121. long m_lMaxSteps;
  122. };
  123. #endif //__STATUSDLG_H_