Source code of Windows XP (NT5)
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.

122 lines
2.7 KiB

  1. // MigrationDriverTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Driver.h"
  5. #import "\bin\MigDrvr.tlb" no_namespace, named_guids
  6. #import "\bin\McsVarSetMin.tlb" no_namespace, named_guids
  7. #include "MigDrvr.h"
  8. #include "VSEdit.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMigrationDriverTestDlg property page
  16. IMPLEMENT_DYNCREATE(CMigrationDriverTestDlg, CPropertyPage)
  17. CMigrationDriverTestDlg::CMigrationDriverTestDlg() : CPropertyPage(CMigrationDriverTestDlg::IDD)
  18. {
  19. //{{AFX_DATA_INIT(CMigrationDriverTestDlg)
  20. // NOTE: the ClassWizard will add member initialization here
  21. //}}AFX_DATA_INIT
  22. }
  23. CMigrationDriverTestDlg::~CMigrationDriverTestDlg()
  24. {
  25. }
  26. void CMigrationDriverTestDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CPropertyPage::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CMigrationDriverTestDlg)
  30. // NOTE: the ClassWizard will add DDX and DDV calls here
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CMigrationDriverTestDlg, CPropertyPage)
  34. //{{AFX_MSG_MAP(CMigrationDriverTestDlg)
  35. ON_BN_CLICKED(IDC_EDIT_VARSET, OnEditVarset)
  36. ON_BN_CLICKED(IDC_GET_DESC, OnGetDesc)
  37. ON_BN_CLICKED(IDC_GO, OnGo)
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CMigrationDriverTestDlg message handlers
  42. void CMigrationDriverTestDlg::OnEditVarset()
  43. {
  44. CVarSetEditDlg vedit;
  45. vedit.SetVarSet(pVarSet);
  46. vedit.DoModal();
  47. pVarSet = vedit.GetVarSet();
  48. }
  49. void CMigrationDriverTestDlg::OnGetDesc()
  50. {
  51. BSTR desc;
  52. HRESULT hr;
  53. CString txt;
  54. if ( pVarSet == NULL )
  55. {
  56. OnEditVarset();
  57. }
  58. hr = pDriver->raw_GetTaskDescription(pVarSet,&desc);
  59. if ( SUCCEEDED(hr) )
  60. {
  61. txt = desc;
  62. }
  63. else
  64. {
  65. txt.Format(L"GetTaskDescription failed, hr=%lx",hr);
  66. }
  67. MessageBox(txt);
  68. }
  69. void CMigrationDriverTestDlg::OnGo()
  70. {
  71. HRESULT hr;
  72. CString txt;
  73. if ( pVarSet == NULL )
  74. {
  75. OnEditVarset();
  76. }
  77. hr = pDriver->raw_PerformMigrationTask(pVarSet,(LONG)m_hWnd);
  78. if ( SUCCEEDED(hr) )
  79. {
  80. txt = "Succeeded!";
  81. }
  82. else
  83. {
  84. txt.Format(L"PerformMigrationTask failed, hr=%lx",hr);
  85. }
  86. MessageBox(txt);
  87. }
  88. BOOL CMigrationDriverTestDlg::OnInitDialog()
  89. {
  90. CPropertyPage::OnInitDialog();
  91. HRESULT hr = pDriver.CreateInstance(CLSID_Migrator);
  92. if ( FAILED(hr) )
  93. {
  94. CString msg;
  95. msg.Format(L"Failed to create Migration Driver, CoCreateInstance returned %lx",hr);
  96. MessageBox(msg);
  97. }
  98. return TRUE; // return TRUE unless you set the focus to a control
  99. // EXCEPTION: OCX Property Pages should return FALSE
  100. }