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.

142 lines
3.2 KiB

  1. // StatusProgress.cpp : Implementation of CStatusProgress
  2. #include "stdafx.h"
  3. #include "Wizchain.h"
  4. #include "StatusProgress.h"
  5. #include "commctrl.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CStatusProgress
  8. STDMETHODIMP CStatusProgress::EnableOnTimerProgress(BOOL bEnable, long lFrequency, long lMaxSteps)
  9. {
  10. if (!m_bOverallProgress && IsWindow(m_hWndProgress))
  11. {
  12. if (bEnable)
  13. {
  14. ::SendMessage(GetParent(m_hWndProgress), WM_STARTTIMER, lFrequency, lMaxSteps);
  15. }
  16. else
  17. {
  18. ::SendMessage(GetParent(m_hWndProgress), WM_KILLTIMER, 0, 0);
  19. }
  20. }
  21. return S_OK;
  22. }
  23. STDMETHODIMP CStatusProgress::get_Position(long *pVal)
  24. {
  25. if (IsWindow(m_hWndProgress))
  26. {
  27. *pVal = ::SendMessage(m_hWndProgress, PBM_GETPOS, 0, 0);
  28. }
  29. return S_OK;
  30. }
  31. STDMETHODIMP CStatusProgress::put_Position(long newVal)
  32. {
  33. if (IsWindow(m_hWndProgress))
  34. {
  35. ::SendMessage(m_hWndProgress, PBM_SETPOS, newVal, 0);
  36. if (!m_bOverallProgress)
  37. {
  38. ::SendMessage(GetParent(m_hWndProgress), WM_KILLTIMER, 0, 0);
  39. ::SendMessage(GetParent(m_hWndProgress), WM_UPDATEOVERALLPROGRESS, 0, 0);
  40. }
  41. }
  42. return S_OK;
  43. }
  44. STDMETHODIMP CStatusProgress::get_Range(long *pVal)
  45. {
  46. PBRANGE range;
  47. range.iHigh = -1;
  48. if (IsWindow(m_hWndProgress))
  49. {
  50. ::SendMessage(m_hWndProgress, PBM_GETRANGE, FALSE, (LPARAM) &range);
  51. if (range.iHigh >= 0)
  52. *pVal = range.iHigh;
  53. else
  54. return E_FAIL;
  55. }
  56. return S_OK;
  57. }
  58. STDMETHODIMP CStatusProgress::put_Range(long newVal)
  59. {
  60. if (IsWindow(m_hWndProgress))
  61. {
  62. if (!::SendMessage(m_hWndProgress, PBM_SETRANGE, 0, MAKELPARAM(0, newVal)))
  63. return E_FAIL;
  64. }
  65. return S_OK;
  66. }
  67. STDMETHODIMP CStatusProgress::put_Step(long newVal)
  68. {
  69. if (IsWindow(m_hWndProgress))
  70. {
  71. ::SendMessage(m_hWndProgress, PBM_SETSTEP, newVal, 0);
  72. }
  73. return S_OK;
  74. }
  75. STDMETHODIMP CStatusProgress::StepIt(long lSteps)
  76. {
  77. if (IsWindow(m_hWndProgress))
  78. {
  79. for (int i = 1; i <= lSteps; i++)
  80. {
  81. ::SendMessage(m_hWndProgress, PBM_STEPIT, 0, 0);
  82. }
  83. if (!m_bOverallProgress)
  84. {
  85. ::SendMessage(GetParent(m_hWndProgress), WM_KILLTIMER, 0, 0);
  86. ::SendMessage(GetParent(m_hWndProgress), WM_UPDATEOVERALLPROGRESS, 0, 0);
  87. }
  88. }
  89. return S_OK;
  90. }
  91. HRESULT CStatusProgress::Initialize(IDispatch * pdispSD, HWND hWnd, BOOL bOverallProgress)
  92. {
  93. m_hWndProgress = hWnd;
  94. m_bOverallProgress = bOverallProgress;
  95. m_pdispSD = pdispSD;
  96. return pdispSD->AddRef();
  97. }
  98. STDMETHODIMP CStatusProgress::put_Text(BSTR newVal)
  99. {
  100. if (IsWindow(m_hWndProgress))
  101. {
  102. if (m_bOverallProgress)
  103. {
  104. ::SetDlgItemText(GetParent(m_hWndProgress), IDC_STATIC_OVERALL, newVal);
  105. }
  106. else
  107. {
  108. ::SetDlgItemText(GetParent(m_hWndProgress), IDC_STATIC_COMPONENT, newVal);
  109. }
  110. }
  111. return S_OK;
  112. }