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.

101 lines
2.4 KiB

  1. // DispatcherTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #import "\bin\McsVarSetMin.tlb" no_namespace, named_guids
  5. #import "\bin\McsDispatcher.tlb" named_guids
  6. #include "Driver.h"
  7. #include "Dispatch.h"
  8. #include "VSEdit.h"
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CDispatcherTestDlg property page
  11. IMPLEMENT_DYNCREATE(CDispatcherTestDlg, CPropertyPage)
  12. CDispatcherTestDlg::CDispatcherTestDlg() : CPropertyPage(CDispatcherTestDlg::IDD)
  13. {
  14. //{{AFX_DATA_INIT(CDispatcherTestDlg)
  15. // NOTE: the ClassWizard will add member initialization here
  16. //}}AFX_DATA_INIT
  17. }
  18. CDispatcherTestDlg::~CDispatcherTestDlg()
  19. {
  20. }
  21. void CDispatcherTestDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CPropertyPage::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CDispatcherTestDlg)
  25. // NOTE: the ClassWizard will add DDX and DDV calls here
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CDispatcherTestDlg, CPropertyPage)
  29. //{{AFX_MSG_MAP(CDispatcherTestDlg)
  30. ON_BN_CLICKED(IDC_DISPATCH, OnDispatch)
  31. ON_BN_CLICKED(IDC_EDIT_VARSET, OnEditVarset)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CDispatcherTestDlg message handlers
  36. void CDispatcherTestDlg::OnDispatch()
  37. {
  38. UpdateData(TRUE);
  39. CWaitCursor w;
  40. if ( pVarSet == NULL )
  41. {
  42. OnEditVarset();
  43. }
  44. if ( pVarSet != NULL )
  45. {
  46. IUnknown * pUnk = NULL;
  47. pVarSet.QueryInterface(IID_IUnknown,&pUnk);
  48. HRESULT hr = pDispatcher->raw_DispatchToServers(&pUnk);
  49. if (SUCCEEDED(hr) )
  50. {
  51. MessageBox(L"DispatchToServers succeeded!");
  52. }
  53. else
  54. {
  55. CString str;
  56. str.Format(L"DispatchToServers failed, hr=%lx",hr);
  57. MessageBox(str);
  58. }
  59. pUnk->Release();
  60. }
  61. else
  62. {
  63. MessageBox(L"The varset pointer is NULL.");
  64. }
  65. }
  66. void CDispatcherTestDlg::OnEditVarset()
  67. {
  68. CVarSetEditDlg vedit;
  69. vedit.SetVarSet(pVarSet);
  70. vedit.DoModal();
  71. pVarSet = vedit.GetVarSet();
  72. }
  73. BOOL CDispatcherTestDlg::OnSetActive()
  74. {
  75. HRESULT hr = pDispatcher.CreateInstance(MCSDISPATCHERLib::CLSID_DCTDispatcher);
  76. if ( FAILED(hr) )
  77. {
  78. CString msg;
  79. msg.Format(L"Failed to create dispatcher, CoCreateInstance returned %lx",hr);
  80. MessageBox(msg);
  81. }
  82. return CPropertyPage::OnSetActive();
  83. }