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.

161 lines
3.3 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. // ClassPg.cpp : implementation file
  8. //
  9. #include "stdafx.h"
  10. #include "WMITest.h"
  11. #include "ClassPg.h"
  12. #include "WMITestDoc.h"
  13. #include "OpView.h"
  14. #include "resource.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CClassPg property page
  22. IMPLEMENT_DYNCREATE(CClassPg, CPropertyPage)
  23. CClassPg::CClassPg() : CPropertyPage(CClassPg::IDD)
  24. {
  25. //{{AFX_DATA_INIT(CClassPg)
  26. // NOTE: the ClassWizard will add member initialization here
  27. //}}AFX_DATA_INIT
  28. }
  29. CClassPg::~CClassPg()
  30. {
  31. }
  32. void CClassPg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CPropertyPage::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CClassPg)
  36. DDX_Control(pDX, IDC_CLASSES, m_ctlClasses);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CClassPg, CPropertyPage)
  40. //{{AFX_MSG_MAP(CClassPg)
  41. ON_LBN_SELCHANGE(IDC_CLASSES, OnSelchangeClasses)
  42. ON_LBN_DBLCLK(IDC_CLASSES, OnDblclkClasses)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CClassPg message handlers
  47. void CClassPg::OnSelchangeClasses()
  48. {
  49. m_pSheet->SetWizardButtons(
  50. m_ctlClasses.GetCurSel() != -1 ? PSWIZB_NEXT : 0);
  51. }
  52. void CClassPg::OnDblclkClasses()
  53. {
  54. m_pSheet->PressButton(PSBTN_NEXT);
  55. }
  56. BOOL CClassPg::OnWizardFinish()
  57. {
  58. // TODO: Add your specialized code here and/or call the base class
  59. return CPropertyPage::OnWizardFinish();
  60. }
  61. LRESULT CClassPg::OnWizardNext()
  62. {
  63. CString strClass;
  64. int iItem = m_ctlClasses.GetCurSel();
  65. if (iItem != -1)
  66. m_ctlClasses.GetText(iItem, strClass);
  67. if (strClass != m_pSheet->m_strClass)
  68. {
  69. m_pSheet->m_strClass = strClass;
  70. m_pSheet->m_listColums.RemoveAll();
  71. m_pSheet->m_bColsNeeded = TRUE;
  72. }
  73. return CPropertyPage::OnWizardNext();
  74. }
  75. BOOL CClassPg::OnInitDialog()
  76. {
  77. CPropertyPage::OnInitDialog();
  78. LoadList();
  79. return TRUE; // return TRUE unless you set the focus to a control
  80. // EXCEPTION: OCX Property Pages should return FALSE
  81. }
  82. void CClassPg::LoadList()
  83. {
  84. CWaitCursor wait;
  85. IEnumWbemClassObject *pEnum = NULL;
  86. HRESULT hr =
  87. m_pSheet->m_pNamespace->CreateClassEnum(
  88. _bstr_t(m_strSuperClass),
  89. WBEM_FLAG_DEEP | WBEM_FLAG_RETURN_IMMEDIATELY |
  90. WBEM_FLAG_FORWARD_ONLY,
  91. NULL,
  92. &pEnum);
  93. if (SUCCEEDED(hr))
  94. {
  95. IWbemClassObject *pObj = NULL;
  96. DWORD nCount;
  97. g_pOpView->GetDocument()->SetInterfaceSecurity(pEnum);
  98. while(SUCCEEDED(hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &nCount)) &&
  99. nCount > 0)
  100. {
  101. CString strClass;
  102. _variant_t var;
  103. if (SUCCEEDED(pObj->Get(L"__CLASS", 0, &var, NULL, NULL)))
  104. {
  105. if (var.vt == VT_BSTR)
  106. {
  107. strClass = var.bstrVal;
  108. m_ctlClasses.AddString(strClass);
  109. }
  110. pObj->Release();
  111. }
  112. }
  113. pEnum->Release();
  114. }
  115. OnSelchangeClasses();
  116. }
  117. BOOL CClassPg::OnSetActive()
  118. {
  119. m_pSheet->SetWizardButtons(m_ctlClasses.GetCurSel() != -1 ? PSWIZB_NEXT : 0);
  120. return CPropertyPage::OnSetActive();
  121. }