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.

825 lines
21 KiB

  1. // THExpressionPage.cpp : implementation file
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // 03/05/00 v-marfin bug 59643 : Make this the default starting page.
  6. // 03/20/00 v-marfin bug 61162 : Changed default rule to "The status changes to Critical"
  7. // 03/27/00 v-marfin bug 60494 : Set correct value for dropdown combo box.
  8. // 03/30/00 v-marfin bug 62674 : Fix to allow editing of string properties.
  9. // 04/07/00 v-marfin bug 62685 : Do not accept empty property names in OnInitDialog.
  10. //
  11. //
  12. //
  13. #include "stdafx.h"
  14. #include "snapin.h"
  15. #include "THExpressionPage.h"
  16. #include "HMObject.h"
  17. #include "HMRuleConfiguration.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CTHExpressionPage property page
  25. IMPLEMENT_DYNCREATE(CTHExpressionPage, CHMPropertyPage)
  26. CTHExpressionPage::CTHExpressionPage() : CHMPropertyPage(CTHExpressionPage::IDD)
  27. {
  28. //{{AFX_DATA_INIT(CTHExpressionPage)
  29. m_sMeasure = _T("");
  30. m_sRuleType = _T("");
  31. m_sCompareTo = _T("");
  32. m_sDataElement = _T("");
  33. m_sDuration = _T("");
  34. m_iComparison = -1;
  35. m_iDurationType = -1;
  36. m_iFunctionType = -1;
  37. m_iCompareTo = -1;
  38. m_sNumericCompareTo = _T("");
  39. m_sTime = _T("");
  40. //}}AFX_DATA_INIT
  41. m_iIntervalMultiple = -1;
  42. m_sHelpTopic = _T("HMon21.chm::/dTHexp.htm");
  43. }
  44. CTHExpressionPage::~CTHExpressionPage()
  45. {
  46. }
  47. void CTHExpressionPage::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CHMPropertyPage::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CTHExpressionPage)
  51. DDX_Control(pDX, IDC_COMBO_FUNCTION, m_FunctionType);
  52. DDX_Control(pDX, IDC_COMBO_RULE_TYPE, m_RuleType);
  53. DDX_Control(pDX, IDC_COMBO_MEASURE, m_Measure);
  54. DDX_Control(pDX, IDC_COMBO_COMPARISON, m_Comparison);
  55. DDX_CBString(pDX, IDC_COMBO_MEASURE, m_sMeasure);
  56. DDX_CBString(pDX, IDC_COMBO_RULE_TYPE, m_sRuleType);
  57. DDX_Text(pDX, IDC_EDIT_COMPARE_TO, m_sCompareTo);
  58. DDX_Text(pDX, IDC_EDIT_DATA_ELEMENT, m_sDataElement);
  59. DDX_Text(pDX, IDC_EDIT_DURATION, m_sDuration);
  60. DDX_CBIndex(pDX, IDC_COMBO_COMPARISON, m_iComparison);
  61. DDX_Radio(pDX, IDC_RADIO_DURATION_ANY, m_iDurationType);
  62. DDX_CBIndex(pDX, IDC_COMBO_FUNCTION, m_iFunctionType);
  63. DDX_CBIndex(pDX, IDC_COMBO_COMPARE_BOOLEAN, m_iCompareTo);
  64. DDX_Text(pDX, IDC_EDIT_COMPARE_NUMERIC, m_sNumericCompareTo);
  65. DDX_Text(pDX, IDC_STATIC_TIME, m_sTime);
  66. //}}AFX_DATA_MAP
  67. if( m_iComparison == 8 )
  68. {
  69. GetDlgItem(IDC_EDIT_DURATION)->EnableWindow(FALSE);
  70. GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
  71. GetDlgItem(IDC_RADIO_DURATION)->EnableWindow(FALSE);
  72. GetDlgItem(IDC_RADIO_DURATION_ANY)->EnableWindow(FALSE);
  73. GetDlgItem(IDC_EDIT_COMPARE_TO)->EnableWindow(FALSE);
  74. GetDlgItem(IDC_COMBO_MEASURE)->EnableWindow(FALSE);
  75. GetDlgItem(IDC_COMBO_FUNCTION)->EnableWindow(FALSE);
  76. }
  77. else
  78. {
  79. if( m_iDurationType == 1 )
  80. {
  81. GetDlgItem(IDC_EDIT_DURATION)->EnableWindow();
  82. GetDlgItem(IDC_SPIN1)->EnableWindow();
  83. }
  84. else
  85. {
  86. GetDlgItem(IDC_EDIT_DURATION)->EnableWindow(FALSE);
  87. GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
  88. }
  89. GetDlgItem(IDC_RADIO_DURATION)->EnableWindow();
  90. GetDlgItem(IDC_RADIO_DURATION_ANY)->EnableWindow();
  91. GetDlgItem(IDC_EDIT_COMPARE_TO)->EnableWindow();
  92. GetDlgItem(IDC_COMBO_MEASURE)->EnableWindow();
  93. GetDlgItem(IDC_COMBO_FUNCTION)->EnableWindow();
  94. }
  95. int iCurSel = m_Measure.GetCurSel();
  96. if( iCurSel == -1 || m_dwaPropertyTypes.GetSize() == 0 )
  97. {
  98. return;
  99. }
  100. if( iCurSel >= m_dwaPropertyTypes.GetSize() )
  101. {
  102. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_HIDE);
  103. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_SHOW);
  104. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_SHOW);
  105. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_HIDE);
  106. return;
  107. }
  108. switch( m_dwaPropertyTypes[iCurSel] )
  109. {
  110. case CIM_SINT8:
  111. case CIM_SINT16:
  112. case CIM_SINT32:
  113. case CIM_SINT64:
  114. case CIM_UINT8:
  115. case CIM_UINT16:
  116. case CIM_UINT32:
  117. case CIM_UINT64:
  118. case CIM_REAL32:
  119. case CIM_REAL64:
  120. {
  121. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_HIDE);
  122. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_SHOW);
  123. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_SHOW);
  124. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_HIDE);
  125. m_CurrentType = Numeric;
  126. }
  127. break;
  128. case CIM_BOOLEAN:
  129. {
  130. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_SHOW);
  131. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_HIDE);
  132. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_HIDE);
  133. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_HIDE);
  134. m_CurrentType = Boolean;
  135. }
  136. break;
  137. case CIM_STRING:
  138. case CIM_DATETIME:
  139. case CIM_REFERENCE:
  140. case CIM_CHAR16:
  141. case CIM_OBJECT:
  142. {
  143. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_HIDE);
  144. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_HIDE);
  145. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_HIDE);
  146. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_SHOW);
  147. m_CurrentType = String;
  148. }
  149. break;
  150. default:
  151. {
  152. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_HIDE);
  153. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_HIDE);
  154. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_HIDE);
  155. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_SHOW);
  156. m_CurrentType = String;
  157. }
  158. }
  159. int iTotalSeconds = m_iIntervalMultiple*_ttoi(m_sDuration);
  160. int iHours = iTotalSeconds/3600;
  161. int iMinutes = (iTotalSeconds/60)%60;
  162. int iSeconds = iTotalSeconds%60;
  163. m_sTime.Empty();
  164. if( iHours )
  165. {
  166. CString sHrs;
  167. sHrs.Format(IDS_STRING_TIME_HOURS_FORMAT,iHours);
  168. m_sTime += sHrs;
  169. }
  170. if( iMinutes )
  171. {
  172. CString sMins;
  173. sMins.Format(IDS_STRING_TIME_MINUTES_FORMAT,iMinutes);
  174. m_sTime += sMins;
  175. }
  176. if( iSeconds )
  177. {
  178. CString sSecs;
  179. sSecs.Format(IDS_STRING_TIME_SECONDS_FORMAT,iSeconds);
  180. m_sTime += sSecs;
  181. }
  182. m_sTime.TrimRight(_T(", "));
  183. m_sTime = _T("(") + m_sTime + _T(")");
  184. GetDlgItem(IDC_STATIC_TIME)->SetWindowText(m_sTime);
  185. }
  186. BEGIN_MESSAGE_MAP(CTHExpressionPage, CHMPropertyPage)
  187. //{{AFX_MSG_MAP(CTHExpressionPage)
  188. ON_CBN_EDITCHANGE(IDC_COMBO_COMPARISON, OnEditchangeComboComparison)
  189. ON_CBN_EDITCHANGE(IDC_COMBO_MEASURE, OnEditchangeComboMeasure)
  190. ON_CBN_EDITCHANGE(IDC_COMBO_RULE_TYPE, OnEditchangeComboRuleType)
  191. ON_EN_CHANGE(IDC_EDIT_COMPARE_TO, OnChangeEditCompareTo)
  192. ON_EN_CHANGE(IDC_EDIT_DATA_ELEMENT, OnChangeEditDataElement)
  193. ON_EN_CHANGE(IDC_EDIT_DURATION, OnChangeEditDuration)
  194. ON_CBN_SELENDOK(IDC_COMBO_COMPARISON, OnSelendokComboComparison)
  195. ON_CBN_SELENDOK(IDC_COMBO_MEASURE, OnSelendokComboMeasure)
  196. ON_CBN_SELENDOK(IDC_COMBO_RULE_TYPE, OnSelendokComboRuleType)
  197. ON_CBN_EDITCHANGE(IDC_COMBO_FUNCTION, OnEditchangeComboFunction)
  198. ON_CBN_SELENDOK(IDC_COMBO_FUNCTION, OnSelendokComboFunction)
  199. ON_BN_CLICKED(IDC_RADIO_DURATION, OnRadioDuration)
  200. ON_BN_CLICKED(IDC_RADIO_DURATION_ANY, OnRadioDurationAny)
  201. ON_EN_CHANGE(IDC_EDIT_COMPARE_NUMERIC, OnChangeEditCompareNumeric)
  202. ON_CBN_SELENDOK(IDC_COMBO_COMPARE_BOOLEAN, OnSelendokComboCompareBoolean)
  203. ON_WM_DESTROY()
  204. //}}AFX_MSG_MAP
  205. END_MESSAGE_MAP()
  206. /////////////////////////////////////////////////////////////////////////////
  207. // CTHExpressionPage message handlers
  208. BOOL CTHExpressionPage::OnInitDialog()
  209. {
  210. // v-marfin : bug 59643 : This will be the default starting page for the property
  211. // sheet so call CnxPropertyPageCreate() to unmarshal the
  212. // connection for this thread. This function must be called
  213. // by the first page of the property sheet. It used to
  214. // be called by the "General" page and its call still remains
  215. // there as well in case the general page is loaded by a
  216. // different code path that does not also load this page.
  217. // The CnxPropertyPageCreate function has been safeguarded
  218. // to simply return if the required call has already been made.
  219. // CnxPropertyPageDestory() must be called from this page's
  220. // OnDestroy function.
  221. // unmarshal connmgr
  222. CnxPropertyPageCreate();
  223. CHMPropertyPage::OnInitDialog();
  224. GetDlgItem(IDC_COMBO_COMPARE_BOOLEAN)->ShowWindow(SW_HIDE);
  225. GetDlgItem(IDC_EDIT_COMPARE_NUMERIC)->ShowWindow(SW_HIDE);
  226. GetDlgItem(IDC_SPIN2)->ShowWindow(SW_HIDE);
  227. GetDlgItem(IDC_EDIT_COMPARE_TO)->ShowWindow(SW_SHOW);
  228. CHMObject* pObject = GetObjectPtr();
  229. if( ! pObject )
  230. {
  231. return FALSE;
  232. }
  233. CHMRuleConfiguration rc;
  234. rc.Create(pObject->GetSystemName());
  235. rc.GetObject(pObject->GetObjectPath());
  236. rc.GetAllProperties();
  237. switch( rc.m_iState )
  238. {
  239. case 9:
  240. {
  241. m_RuleType.SetCurSel(0); // critical
  242. }
  243. break;
  244. case 8:
  245. {
  246. m_RuleType.SetCurSel(1);
  247. }
  248. break;
  249. case 3:
  250. {
  251. m_RuleType.SetCurSel(2);
  252. }
  253. break;
  254. case 1: // v-marfin 60494
  255. {
  256. m_RuleType.SetCurSel(3);
  257. }
  258. break;
  259. case 0:
  260. {
  261. // v-marfin bug 61162 m_RuleType.SetCurSel(3);
  262. // default rule for threshold should be "The status changes to critical"
  263. m_RuleType.SetCurSel(0);
  264. }
  265. break;
  266. }
  267. m_Comparison.SetCurSel(rc.m_iRuleCondition);
  268. UpdateData();
  269. // get parent object to fill in the data element field
  270. CWbemClassObject* pClassObject = pObject->GetParentClassObject();
  271. if( ! pClassObject )
  272. {
  273. return FALSE;
  274. }
  275. CString sNamespace;
  276. CString sClass;
  277. CStringArray saPropertyNames;
  278. m_iIntervalMultiple = 0;
  279. pClassObject->GetLocaleStringProperty(IDS_STRING_MOF_NAME,m_sDataElement);
  280. pClassObject->GetProperty(IDS_STRING_MOF_TARGETNAMESPACE,sNamespace);
  281. pClassObject->GetProperty(IDS_STRING_MOF_PATH,sClass);
  282. //---------------------------------------------------------------------------------
  283. // 62685 : Do not accept empty property names
  284. pClassObject->GetProperty(IDS_STRING_MOF_STATISTICSPROPERTYNAMES,saPropertyNames);
  285. int nSize = (int)saPropertyNames.GetSize()-1;
  286. for (int x=nSize; x>=0; x--)
  287. {
  288. if (saPropertyNames[x].IsEmpty())
  289. {
  290. saPropertyNames.RemoveAt(x);
  291. }
  292. }
  293. //
  294. // This is really a larger problem: When some data collectors are created, they
  295. // have default properties automatically created via the mof. But upon initial
  296. // creation, if the user changes the CLASS or INSTANCE for example on the property
  297. // page and selects different properties, the old properties are not removed. This
  298. // causes problems when new thresholds are created for the data collector. The solution
  299. // is to ensure that in the data collector property page, when key data such as CLASS
  300. // or INSTANCE changes, the existing properties are removed.
  301. // For now (beta) just remove the empty names from the array.
  302. //---------------------------------------------------------------------------------
  303. //
  304. pClassObject->GetProperty(IDS_STRING_MOF_COLLECTIONINTERVAL,m_iIntervalMultiple);
  305. if( ! sClass.IsEmpty() )
  306. {
  307. int iIndex = -1;
  308. if( (iIndex = sClass.Find(_T("."))) != -1 )
  309. {
  310. sClass = sClass.Left(iIndex);
  311. }
  312. }
  313. CString sQuery;
  314. pClassObject->GetProperty(IDS_STRING_MOF_QUERY,sQuery);
  315. if( sClass.IsEmpty() && !sQuery.IsEmpty() )
  316. {
  317. sQuery.MakeUpper();
  318. int iIndex = -1;
  319. if( (iIndex = sQuery.Find(_T("ISA"))) != -1 )
  320. {
  321. sClass = sQuery.Right(sQuery.GetLength()-iIndex-4);
  322. iIndex = sClass.Find(_T(" "));
  323. if( iIndex != -1 )
  324. {
  325. sClass = sClass.Left(iIndex);
  326. }
  327. sClass.TrimLeft(_T("\""));
  328. sClass.TrimRight(_T("\""));
  329. }
  330. else
  331. {
  332. iIndex = sQuery.Find(_T("SELECT * FROM "));
  333. if( iIndex != -1 )
  334. {
  335. sClass = sQuery.Right(sQuery.GetLength()-iIndex-14);
  336. iIndex = sClass.Find(_T(" "));
  337. if( iIndex != -1 )
  338. {
  339. sClass = sClass.Left(iIndex);
  340. }
  341. }
  342. }
  343. }
  344. delete pClassObject;
  345. pClassObject = NULL;
  346. m_iFunctionType = rc.m_iUseFlag;
  347. if( rc.m_iRuleDuration )
  348. {
  349. m_sDuration.Format(_T("%d"),rc.m_iRuleDuration);
  350. m_iDurationType = 1;
  351. GetDlgItem(IDC_EDIT_DURATION)->EnableWindow();
  352. }
  353. else
  354. {
  355. m_iDurationType = 0;
  356. }
  357. // we need to get the WMI class object that the data element is pointing to
  358. // so that we can read in the type of each property
  359. pClassObject = new CWbemClassObject;
  360. pClassObject->SetNamespace(_T("\\\\") + pObject->GetSystemName() + _T("\\") + sNamespace);
  361. HRESULT hr = pClassObject->GetObject(sClass);
  362. pClassObject->GetPropertyNames(saPropertyNames);
  363. for( int i = 0; i < saPropertyNames.GetSize(); i++ )
  364. {
  365. CString sType;
  366. if( hr == S_OK )
  367. {
  368. long lType;
  369. pClassObject->GetPropertyType(saPropertyNames[i],sType);
  370. pClassObject->GetPropertyType(saPropertyNames[i],lType);
  371. // m_dwaPropertyTypes.Add(lType); // v-marfin 62674
  372. // v-marfin 61636
  373. // Send to function that will check first for dup entries and not add
  374. // if duplicated.
  375. // m_Measure.AddString(_T("[") + sType + _T("] ") + saPropertyNames[i]);
  376. if (AddToMeasureCombo(sType,saPropertyNames[i])) // v-marfin 61811 Check to see if we added the item first
  377. {
  378. m_dwaPropertyTypes.Add(lType); // v-marfin 62674 Only add if it passed above check
  379. if( saPropertyNames[i].CompareNoCase(rc.m_sPropertyName) == 0 )
  380. {
  381. if( lType == CIM_BOOLEAN )
  382. {
  383. if( rc.m_sRuleValue == _T("1") )
  384. {
  385. m_iCompareTo = 1;
  386. }
  387. else
  388. {
  389. m_iCompareTo = 0;
  390. }
  391. }
  392. else
  393. {
  394. m_sCompareTo = rc.m_sRuleValue;
  395. m_sNumericCompareTo = rc.m_sRuleValue;
  396. }
  397. }
  398. } // if (AddToMeasureCombo(sType,saPropertyNames[i]))
  399. }
  400. else
  401. {
  402. m_Measure.AddString(saPropertyNames[i]);
  403. }
  404. }
  405. m_Measure.AddString(_T("HMNumInstancesCollected"));
  406. if( hr == S_OK )
  407. {
  408. CString sType;
  409. pClassObject->GetPropertyType(rc.m_sPropertyName,sType);
  410. m_sMeasure = _T("[") + sType + _T("] ") + rc.m_sPropertyName;
  411. }
  412. else
  413. {
  414. m_sMeasure = rc.m_sPropertyName;
  415. m_sCompareTo = rc.m_sRuleValue;
  416. }
  417. delete pClassObject;
  418. pClassObject = NULL;
  419. UpdateData(FALSE);
  420. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,INT_MAX-1);
  421. SendDlgItemMessage(IDC_SPIN2,UDM_SETRANGE32,0,INT_MAX-1);
  422. return TRUE; // return TRUE unless you set the focus to a control
  423. // EXCEPTION: OCX Property Pages should return FALSE
  424. }
  425. void CTHExpressionPage::OnOK()
  426. {
  427. CHMPropertyPage::OnOK();
  428. }
  429. BOOL CTHExpressionPage::OnApply()
  430. {
  431. if( ! CHMPropertyPage::OnApply() )
  432. {
  433. return FALSE;
  434. }
  435. UpdateData();
  436. CWbemClassObject* pClassObject = GetObjectPtr()->GetClassObject();
  437. if( ! pClassObject )
  438. {
  439. return FALSE;
  440. }
  441. HRESULT hr = S_OK;
  442. int iIndex = -1;
  443. if( (iIndex = m_sMeasure.Find(_T("] "))) != -1 )
  444. {
  445. m_sMeasure = m_sMeasure.Right(m_sMeasure.GetLength()-(iIndex+2));
  446. }
  447. if( m_CurrentType == String )
  448. {
  449. hr = pClassObject->SetProperty(IDS_STRING_MOF_RULEVALUE,m_sCompareTo);
  450. }
  451. else if( m_CurrentType == Numeric )
  452. {
  453. hr = pClassObject->SetProperty(IDS_STRING_MOF_RULEVALUE,m_sNumericCompareTo);
  454. }
  455. else if( m_CurrentType == Boolean )
  456. {
  457. CString sValue;
  458. sValue.Format(_T("%d"),m_iCompareTo);
  459. hr = pClassObject->SetProperty(IDS_STRING_MOF_RULEVALUE,sValue);
  460. }
  461. switch( m_RuleType.GetCurSel() )
  462. {
  463. case 0:
  464. {
  465. hr = pClassObject->SetProperty(IDS_STRING_MOF_STATE,9);
  466. }
  467. break;
  468. case 1:
  469. {
  470. hr = pClassObject->SetProperty(IDS_STRING_MOF_STATE,8);
  471. }
  472. break;
  473. case 2:
  474. {
  475. hr = pClassObject->SetProperty(IDS_STRING_MOF_STATE,3);
  476. }
  477. break;
  478. case 3:
  479. {
  480. // v-marfin 60494 : Set correct value
  481. hr = pClassObject->SetProperty(IDS_STRING_MOF_STATE,1); // 0
  482. }
  483. break;
  484. }
  485. hr = pClassObject->SetProperty(IDS_STRING_MOF_RULECONDITION,m_Comparison.GetCurSel());
  486. hr = pClassObject->SetProperty(IDS_STRING_MOF_PROPERTYNAME,m_sMeasure);
  487. hr = pClassObject->SetProperty(IDS_STRING_MOF_USEFLAG,m_iFunctionType);
  488. int iDuration;
  489. if( m_iDurationType == 1 )
  490. {
  491. iDuration = _ttoi(m_sDuration);
  492. }
  493. else
  494. {
  495. iDuration = 0;
  496. }
  497. hr = pClassObject->SetProperty(IDS_STRING_MOF_RULEDURATION,iDuration);
  498. pClassObject->SaveAllProperties();
  499. CString sName;
  500. pClassObject->GetProperty(IDS_STRING_MOF_NAME,sName);
  501. delete pClassObject;
  502. CStringArray saPropertyNames;
  503. CWbemClassObject* pParentObject = GetObjectPtr()->GetParentClassObject();
  504. if( pParentObject )
  505. {
  506. pParentObject->GetProperty(IDS_STRING_MOF_STATISTICSPROPERTYNAMES,saPropertyNames);
  507. bool bFound = false;
  508. for( int i = 0; i < saPropertyNames.GetSize(); i++ )
  509. {
  510. if( saPropertyNames[i] == m_sMeasure )
  511. {
  512. bFound = true;
  513. break;
  514. }
  515. }
  516. if( ! bFound )
  517. {
  518. saPropertyNames.Add(m_sMeasure);
  519. pParentObject->SetProperty(IDS_STRING_MOF_STATISTICSPROPERTYNAMES,saPropertyNames);
  520. pParentObject->SaveAllProperties();
  521. }
  522. delete pParentObject;
  523. }
  524. SetModified(FALSE);
  525. GetObjectPtr()->Rename(sName);
  526. return TRUE;
  527. }
  528. void CTHExpressionPage::OnEditchangeComboComparison()
  529. {
  530. if( m_FunctionType.GetSafeHwnd() == NULL )
  531. {
  532. return;
  533. }
  534. UpdateData();
  535. SetModified();
  536. }
  537. void CTHExpressionPage::OnEditchangeComboMeasure()
  538. {
  539. if( m_FunctionType.GetSafeHwnd() == NULL )
  540. {
  541. return;
  542. }
  543. UpdateData();
  544. SetModified();
  545. }
  546. void CTHExpressionPage::OnEditchangeComboRuleType()
  547. {
  548. if( m_FunctionType.GetSafeHwnd() == NULL )
  549. {
  550. return;
  551. }
  552. UpdateData();
  553. SetModified();
  554. }
  555. void CTHExpressionPage::OnChangeEditCompareTo()
  556. {
  557. // TODO: If this is a RICHEDIT control, the control will not
  558. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  559. // function and call CRichEditCtrl().SetEventMask()
  560. // with the ENM_CHANGE flag ORed into the mask.
  561. if( m_FunctionType.GetSafeHwnd() == NULL )
  562. {
  563. return;
  564. }
  565. UpdateData();
  566. SetModified();
  567. }
  568. void CTHExpressionPage::OnChangeEditDataElement()
  569. {
  570. // TODO: If this is a RICHEDIT control, the control will not
  571. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  572. // function and call CRichEditCtrl().SetEventMask()
  573. // with the ENM_CHANGE flag ORed into the mask.
  574. if( m_FunctionType.GetSafeHwnd() == NULL )
  575. {
  576. return;
  577. }
  578. UpdateData();
  579. SetModified();
  580. }
  581. void CTHExpressionPage::OnChangeEditDuration()
  582. {
  583. // TODO: If this is a RICHEDIT control, the control will not
  584. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  585. // function and call CRichEditCtrl().SetEventMask()
  586. // with the ENM_CHANGE flag ORed into the mask.
  587. if( m_FunctionType.GetSafeHwnd() == NULL )
  588. {
  589. return;
  590. }
  591. UpdateData();
  592. SetModified();
  593. }
  594. void CTHExpressionPage::OnChangeEditCompareNumeric()
  595. {
  596. // TODO: If this is a RICHEDIT control, the control will not
  597. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  598. // function and call CRichEditCtrl().SetEventMask()
  599. // with the ENM_CHANGE flag ORed into the mask.
  600. if( m_FunctionType.GetSafeHwnd() == NULL )
  601. {
  602. return;
  603. }
  604. UpdateData();
  605. SetModified();
  606. }
  607. void CTHExpressionPage::OnSelendokComboComparison()
  608. {
  609. if( m_FunctionType.GetSafeHwnd() == NULL )
  610. {
  611. return;
  612. }
  613. UpdateData();
  614. SetModified();
  615. }
  616. void CTHExpressionPage::OnSelendokComboMeasure()
  617. {
  618. if( m_FunctionType.GetSafeHwnd() == NULL )
  619. {
  620. return;
  621. }
  622. UpdateData();
  623. SetModified();
  624. }
  625. void CTHExpressionPage::OnSelendokComboRuleType()
  626. {
  627. if( m_FunctionType.GetSafeHwnd() == NULL )
  628. {
  629. return;
  630. }
  631. UpdateData();
  632. SetModified();
  633. }
  634. void CTHExpressionPage::OnEditchangeComboFunction()
  635. {
  636. if( m_FunctionType.GetSafeHwnd() == NULL )
  637. {
  638. return;
  639. }
  640. UpdateData();
  641. SetModified();
  642. }
  643. void CTHExpressionPage::OnSelendokComboFunction()
  644. {
  645. if( m_FunctionType.GetSafeHwnd() == NULL )
  646. {
  647. return;
  648. }
  649. UpdateData();
  650. SetModified();
  651. }
  652. void CTHExpressionPage::OnRadioDuration()
  653. {
  654. if( m_FunctionType.GetSafeHwnd() == NULL )
  655. {
  656. return;
  657. }
  658. UpdateData();
  659. SetModified();
  660. }
  661. void CTHExpressionPage::OnRadioDurationAny()
  662. {
  663. if( m_FunctionType.GetSafeHwnd() == NULL )
  664. {
  665. return;
  666. }
  667. UpdateData();
  668. SetModified();
  669. }
  670. void CTHExpressionPage::OnSelendokComboCompareBoolean()
  671. {
  672. if( m_FunctionType.GetSafeHwnd() == NULL )
  673. {
  674. return;
  675. }
  676. UpdateData();
  677. SetModified();
  678. }
  679. //***********************************************************************
  680. // AddToMeasureCombo v-marfin bug 61636
  681. //***********************************************************************
  682. BOOL CTHExpressionPage::AddToMeasureCombo(CString &sType, CString &sName)
  683. {
  684. // Check for duplicate before adding.
  685. // Format it for display
  686. CString sEntry = _T("[") + sType + _T("] ") + sName;
  687. // Does it already exist? -1 = search entire combo
  688. if (m_Measure.FindStringExact(-1, (LPCTSTR)sEntry ) != CB_ERR)
  689. return FALSE; // v-marfin 61811 : FALSE means we did not add it
  690. // Add it
  691. m_Measure.AddString(sEntry);
  692. return TRUE;
  693. }
  694. void CTHExpressionPage::OnDestroy()
  695. {
  696. CHMPropertyPage::OnDestroy();
  697. // v-marfin : bug 59643 : CnxPropertyPageDestory() must be called from this page's
  698. // OnDestroy function.
  699. CnxPropertyPageDestroy();
  700. }