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.

168 lines
3.3 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. // ParamsPg.cpp : implementation file
  8. //
  9. #include "stdafx.h"
  10. #include "wmitest.h"
  11. #include "WMITestDoc.h"
  12. #include "OpView.h"
  13. #include "OpWrap.h"
  14. #include "ParamsPg.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CParamsPg property page
  22. IMPLEMENT_DYNCREATE(CParamsPg, CPropertyPage)
  23. CParamsPg::CParamsPg() : CPropertyPage(CParamsPg::IDD)
  24. {
  25. //{{AFX_DATA_INIT(CParamsPg)
  26. m_strName = _T("");
  27. //}}AFX_DATA_INIT
  28. }
  29. CParamsPg::~CParamsPg()
  30. {
  31. }
  32. void CParamsPg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CPropertyPage::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CParamsPg)
  36. DDX_Text(pDX, IDC_NAME, m_strName);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CParamsPg, CPropertyPage)
  40. //{{AFX_MSG_MAP(CParamsPg)
  41. ON_BN_CLICKED(IDC_EDIT_INPUT, OnEditInput)
  42. ON_BN_CLICKED(IDC_EDIT_OUT, OnEditOut)
  43. ON_BN_CLICKED(IDC_NULL_IN, OnNullIn)
  44. ON_BN_CLICKED(IDC_NULL_OUT, OnNullOut)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CParamsPg message handlers
  49. BOOL CParamsPg::EditParams(DWORD dwID, IWbemClassObjectPtr &pObj)
  50. {
  51. HRESULT hr;
  52. if (pObj == NULL)
  53. {
  54. //IWbemClassObjectPtr pClass;
  55. if (SUCCEEDED(hr = g_pOpView->GetDocument()->m_pNamespace->GetObject(
  56. L"__PARAMETERS",
  57. WBEM_FLAG_RETURN_WBEM_COMPLETE,
  58. NULL,
  59. &pObj,
  60. NULL)))
  61. {
  62. //_variant_t vValue = dwID == IDS_EDIT_IN_PARAMS ? L"InParams"
  63. //hr =
  64. // pClass->SpawnInstance(
  65. // 0,
  66. // ppObj);
  67. }
  68. if (FAILED(hr))
  69. {
  70. CWMITestDoc::DisplayWMIErrorBox(hr);
  71. return FALSE;
  72. }
  73. }
  74. return CWMITestDoc::EditGenericObject(dwID, pObj);
  75. }
  76. void CParamsPg::OnEditInput()
  77. {
  78. EditParams(IDS_EDIT_IN_PARAMS, m_pObjIn);
  79. }
  80. void CParamsPg::OnEditOut()
  81. {
  82. EditParams(IDS_EDIT_OUT_PARAMS, m_pObjOut);
  83. }
  84. void CParamsPg::OnNullIn()
  85. {
  86. GetDlgItem(IDC_EDIT_INPUT)->EnableWindow(
  87. !IsDlgButtonChecked(IDC_NULL_IN));
  88. }
  89. void CParamsPg::OnNullOut()
  90. {
  91. GetDlgItem(IDC_EDIT_OUT)->EnableWindow(
  92. !IsDlgButtonChecked(IDC_NULL_OUT));
  93. }
  94. BOOL CParamsPg::OnInitDialog()
  95. {
  96. CPropertyPage::OnInitDialog();
  97. if (!m_bNewMethod)
  98. {
  99. m_pClass->GetMethod(
  100. _bstr_t(m_strName),
  101. 0,
  102. &m_pObjIn,
  103. &m_pObjOut);
  104. }
  105. GetDlgItem(IDC_NAME)->EnableWindow(m_bNewMethod);
  106. CheckDlgButton(IDC_NULL_IN, m_pObjIn == NULL);
  107. OnNullIn();
  108. CheckDlgButton(IDC_NULL_OUT, m_pObjOut == NULL);
  109. OnNullOut();
  110. return TRUE; // return TRUE unless you set the focus to a control
  111. // EXCEPTION: OCX Property Pages should return FALSE
  112. }
  113. void CParamsPg::OnOK()
  114. {
  115. if (IsDlgButtonChecked(IDC_NULL_IN))
  116. m_pObjIn = NULL;
  117. if (IsDlgButtonChecked(IDC_NULL_OUT))
  118. m_pObjOut = NULL;
  119. CPropertyPage::OnOK();
  120. }
  121. BOOL CParamsPg::OnKillActive()
  122. {
  123. if (m_strName.IsEmpty())
  124. {
  125. AfxMessageBox(IDS_METHOD_NAME_IS_EMPTY, MB_ICONEXCLAMATION | MB_OK);
  126. return FALSE;
  127. }
  128. return CPropertyPage::OnKillActive();
  129. }