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.

144 lines
2.6 KiB

  1. //
  2. // Microsoft Windows Media Technologies
  3. // Copyright (C) Microsoft Corporation, 1999 - 2001. All rights reserved.
  4. //
  5. //
  6. // ProgressHelper.cpp : Implementation of CProgressHelper
  7. //
  8. #include "progPCH.h"
  9. #include "ProgHelp.h"
  10. #include "ProgressHelper.h"
  11. #include <stdio.h>
  12. //
  13. // Constructor/Destructor
  14. //
  15. CProgressHelper::CProgressHelper()
  16. {
  17. m_hwnd = 0;
  18. m_uMsg = 0;
  19. FillMemory( &m_progressnotify, sizeof(m_progressnotify), 0 );
  20. m_fCancelled = FALSE;
  21. }
  22. CProgressHelper::~CProgressHelper()
  23. {
  24. }
  25. //
  26. // IWMDMProgress methods
  27. //
  28. HRESULT CProgressHelper::Begin( DWORD dwEstimatedTicks )
  29. {
  30. // Check notification values
  31. //
  32. if( !m_hwnd || !m_uMsg )
  33. {
  34. return E_FAIL;
  35. }
  36. // Check if the user has cancelled this operation
  37. //
  38. if( m_fCancelled )
  39. {
  40. return WMDM_E_USER_CANCELLED;
  41. }
  42. // Populate the notify structure with the valid values
  43. //
  44. m_progressnotify.dwMsg = SFM_BEGIN;
  45. m_progressnotify.dwTotalTicks = dwEstimatedTicks;
  46. // Send the message to the notification window
  47. //
  48. SendMessage( m_hwnd, m_uMsg, 0, (LPARAM)&m_progressnotify );
  49. return S_OK;
  50. }
  51. HRESULT CProgressHelper::Progress( DWORD dwTranspiredTicks )
  52. {
  53. // Check notification values
  54. //
  55. if( !m_hwnd || !m_uMsg )
  56. {
  57. return E_FAIL;
  58. }
  59. // Check if the user has cancelled this operation
  60. //
  61. if( m_fCancelled )
  62. {
  63. return WMDM_E_USER_CANCELLED;
  64. }
  65. // Populate the notify structure with the valid values
  66. //
  67. m_progressnotify.dwMsg = SFM_PROGRESS;
  68. m_progressnotify.dwCurrentTicks = dwTranspiredTicks;
  69. // Send the message to the notification window
  70. //
  71. SendMessage( m_hwnd, m_uMsg, 0, (LPARAM)&m_progressnotify );
  72. return S_OK;
  73. }
  74. HRESULT CProgressHelper::End()
  75. {
  76. // Check notification values
  77. //
  78. if( !m_hwnd || !m_uMsg )
  79. {
  80. return E_FAIL;
  81. }
  82. // Check if the user has cancelled this operation
  83. //
  84. if( m_fCancelled )
  85. {
  86. return WMDM_E_USER_CANCELLED;
  87. }
  88. // Populate the notify structure with the valid values
  89. //
  90. m_progressnotify.dwMsg = SFM_END;
  91. m_progressnotify.dwCurrentTicks = m_progressnotify.dwTotalTicks;
  92. // Send the message to the notification window
  93. //
  94. SendMessage( m_hwnd, m_uMsg, 0, (LPARAM)&m_progressnotify );
  95. return S_OK;
  96. }
  97. //
  98. // IWMDMProgressHelper methods
  99. //
  100. HRESULT CProgressHelper::SetNotification( HWND hwnd, UINT uMsg )
  101. {
  102. if( !hwnd || !uMsg || uMsg < WM_USER )
  103. {
  104. return E_INVALIDARG;
  105. }
  106. m_hwnd = hwnd;
  107. m_uMsg = uMsg;
  108. return S_OK;
  109. }
  110. HRESULT CProgressHelper::Cancel( void )
  111. {
  112. m_fCancelled = TRUE;
  113. return S_OK;
  114. }