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.

171 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module asyncdlg.cpp | Implementation of the CAsyncDlg dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 10/10/1999
  9. Revision History:
  10. Name Date Comments
  11. aoltean 10/10/1999 Created
  12. --*/
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Includes
  15. #include "stdafx.hxx"
  16. #include "resource.h"
  17. #include "GenDlg.h"
  18. #include "VssTest.h"
  19. #include "AsyncDlg.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CAsyncDlg dialog
  27. CAsyncDlg::CAsyncDlg(
  28. IVssAsync *pIAsync,
  29. CWnd* pParent
  30. )
  31. : CVssTestGenericDlg(CAsyncDlg::IDD, pParent),
  32. m_pIAsync(pIAsync)
  33. {
  34. //{{AFX_DATA_INIT(CAsyncDlg)
  35. //}}AFX_DATA_INIT
  36. m_strState.Empty();
  37. m_strPercentCompleted.Empty();
  38. }
  39. CAsyncDlg::~CAsyncDlg()
  40. {
  41. }
  42. void CAsyncDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CVssTestGenericDlg::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAsyncDlg)
  46. DDX_Text(pDX, IDC_ASYNC_STATUS, m_strState);
  47. DDX_Text(pDX, IDC_ASYNC_PERF, m_strPercentCompleted);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CAsyncDlg, CVssTestGenericDlg)
  51. //{{AFX_MSG_MAP(CAsyncDlg)
  52. ON_BN_CLICKED(IDC_NEXT, OnNext)
  53. ON_BN_CLICKED(IDC_ASYNC_WAIT, OnWait)
  54. ON_BN_CLICKED(IDC_ASYNC_CANCEL, OnCancel)
  55. ON_BN_CLICKED(IDC_ASYNC_QUERY, OnQueryStatus)
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CAsyncDlg message handlers
  60. BOOL CAsyncDlg::OnInitDialog()
  61. {
  62. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CAsyncDlg::OnInitDialog" );
  63. USES_CONVERSION;
  64. try
  65. {
  66. CVssTestGenericDlg::OnInitDialog();
  67. UpdateData(FALSE);
  68. }
  69. VSS_STANDARD_CATCH(ft)
  70. return TRUE; // return TRUE unless you set the focus to a control
  71. }
  72. void CAsyncDlg::OnNext()
  73. {
  74. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CAsyncDlg::OnNext" );
  75. try
  76. {
  77. EndDialog(IDOK);
  78. }
  79. VSS_STANDARD_CATCH(ft)
  80. }
  81. void CAsyncDlg::OnWait()
  82. {
  83. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CCoordDlg::OnWait" );
  84. try
  85. {
  86. ft.hr = m_pIAsync->Wait();
  87. if (ft.hr != S_OK)
  88. ft.MsgBox( L"Return value", L"Wait returned 0x%08lx", ft.hr );
  89. }
  90. VSS_STANDARD_CATCH(ft)
  91. }
  92. void CAsyncDlg::OnCancel()
  93. {
  94. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CCoordDlg::OnCancel" );
  95. try
  96. {
  97. ft.hr = m_pIAsync->Cancel();
  98. if (ft.hr != S_OK)
  99. ft.MsgBox( L"Return value", L"Cancel returned 0x%08lx", ft.hr );
  100. }
  101. VSS_STANDARD_CATCH(ft)
  102. }
  103. void CAsyncDlg::OnQueryStatus()
  104. {
  105. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CCoordDlg::OnQueryStatus" );
  106. try
  107. {
  108. HRESULT hrResult = S_OK;
  109. INT nPercentDone = 0;
  110. ft.hr = m_pIAsync->QueryStatus(&hrResult, &nPercentDone);
  111. WCHAR wszBuffer[30];
  112. wsprintfW(wszBuffer, L"0x%08lx", hrResult);
  113. m_strState = W2T(wszBuffer);
  114. wsprintfW(wszBuffer, L"%3d.%02d %%", nPercentDone/100, nPercentDone%100 );
  115. m_strPercentCompleted = W2T(wszBuffer);
  116. if (ft.hr != S_OK)
  117. ft.MsgBox( L"Return value", L"Cancel returned 0x%08lx", ft.hr );
  118. UpdateData(FALSE);
  119. }
  120. VSS_STANDARD_CATCH(ft)
  121. }