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.

192 lines
4.7 KiB

  1. // THMessagePage.cpp : implementation file
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // 03/24/00 v-marfin 62191 : help link fix.
  6. // 03/28/00 v-marfin 62489 : set range on alert ID spin control
  7. //
  8. //
  9. #include "stdafx.h"
  10. #include "snapin.h"
  11. #include "THMessagePage.h"
  12. #include "Rule.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CTHMessagePage property page
  20. IMPLEMENT_DYNCREATE(CTHMessagePage, CHMPropertyPage)
  21. CTHMessagePage::CTHMessagePage() : CHMPropertyPage(CTHMessagePage::IDD)
  22. {
  23. //{{AFX_DATA_INIT(CTHMessagePage)
  24. m_sResetMessage = _T("");
  25. m_sViolationMessage = _T("");
  26. m_iID = 0;
  27. //}}AFX_DATA_INIT
  28. m_sHelpTopic = _T("HMon21.chm::/dTHmessage.htm"); // v-marfin 62191 : help link fix
  29. }
  30. CTHMessagePage::~CTHMessagePage()
  31. {
  32. }
  33. void CTHMessagePage::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CHMPropertyPage::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CTHMessagePage)
  37. DDX_Control(pDX, IDC_EDIT_VIOLATION_MESSAGE, m_ViolationMessage);
  38. DDX_Control(pDX, IDC_EDIT_RESET_MESSAGE, m_ResetMessage);
  39. DDX_Text(pDX, IDC_EDIT_RESET_MESSAGE, m_sResetMessage);
  40. DDX_Text(pDX, IDC_EDIT_VIOLATION_MESSAGE, m_sViolationMessage);
  41. DDX_Text(pDX, IDC_EDIT_ID, m_iID);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CTHMessagePage, CHMPropertyPage)
  45. //{{AFX_MSG_MAP(CTHMessagePage)
  46. ON_EN_CHANGE(IDC_EDIT_RESET_MESSAGE, OnChangeEditResetMessage)
  47. ON_EN_CHANGE(IDC_EDIT_VIOLATION_MESSAGE, OnChangeEditViolationMessage)
  48. ON_BN_CLICKED(IDC_BUTTON_INSERTION, OnButtonInsertion)
  49. ON_BN_CLICKED(IDC_BUTTON_INSERTION2, OnButtonInsertion2)
  50. ON_EN_CHANGE(IDC_EDIT_ID, OnChangeEditId)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CTHMessagePage message handlers
  55. BOOL CTHMessagePage::OnInitDialog()
  56. {
  57. CHMPropertyPage::OnInitDialog();
  58. if( ! m_InsertionMenu.Create(&m_ViolationMessage,GetObjectPtr()) )
  59. {
  60. GetDlgItem(IDC_BUTTON_INSERTION)->EnableWindow(FALSE);
  61. }
  62. if( ! m_InsertionMenu2.Create(&m_ResetMessage,GetObjectPtr()) )
  63. {
  64. GetDlgItem(IDC_BUTTON_INSERTION2)->EnableWindow(FALSE);
  65. }
  66. CWbemClassObject* pClassObject = GetObjectPtr()->GetClassObject();
  67. if( ! GfxCheckObjPtr(pClassObject,CWbemClassObject) )
  68. {
  69. return TRUE;
  70. }
  71. pClassObject->GetLocaleStringProperty(IDS_STRING_MOF_MESSAGE,m_sViolationMessage);
  72. pClassObject->GetLocaleStringProperty(IDS_STRING_MOF_RESETMESSAGE,m_sResetMessage);
  73. pClassObject->GetProperty(IDS_STRING_MOF_ID,m_iID);
  74. delete pClassObject;
  75. pClassObject = NULL;
  76. m_ViolationMessage.SetCaretPos(CPoint(0,0));
  77. m_ResetMessage.SetCaretPos(CPoint(0,0));
  78. // v-marfin 62489 : set range on alert ID spin control
  79. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,INT_MAX-1);
  80. UpdateData(FALSE);
  81. return TRUE; // return TRUE unless you set the focus to a control
  82. // EXCEPTION: OCX Property Pages should return FALSE
  83. }
  84. BOOL CTHMessagePage::OnApply()
  85. {
  86. if( ! CHMPropertyPage::OnApply() )
  87. {
  88. return FALSE;
  89. }
  90. UpdateData();
  91. CWbemClassObject* pClassObject = GetObjectPtr()->GetClassObject();
  92. if( ! GfxCheckObjPtr(pClassObject,CWbemClassObject) )
  93. {
  94. return FALSE;
  95. }
  96. pClassObject->SetProperty(IDS_STRING_MOF_MESSAGE,m_sViolationMessage);
  97. pClassObject->SetProperty(IDS_STRING_MOF_RESETMESSAGE,m_sResetMessage);
  98. pClassObject->SetProperty(IDS_STRING_MOF_ID,m_iID);
  99. pClassObject->SaveAllProperties();
  100. delete pClassObject;
  101. pClassObject = NULL;
  102. SetModified(FALSE);
  103. return TRUE;
  104. }
  105. void CTHMessagePage::OnChangeEditResetMessage()
  106. {
  107. // TODO: If this is a RICHEDIT control, the control will not
  108. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  109. // function and call CRichEditCtrl().SetEventMask()
  110. // with the ENM_CHANGE flag ORed into the mask.
  111. UpdateData();
  112. SetModified(TRUE);
  113. }
  114. void CTHMessagePage::OnChangeEditViolationMessage()
  115. {
  116. // TODO: If this is a RICHEDIT control, the control will not
  117. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  118. // function and call CRichEditCtrl().SetEventMask()
  119. // with the ENM_CHANGE flag ORed into the mask.
  120. UpdateData();
  121. SetModified(TRUE);
  122. }
  123. void CTHMessagePage::OnButtonInsertion()
  124. {
  125. CPoint pt;
  126. GetCursorPos(&pt);
  127. m_InsertionMenu.DisplayMenu(pt);
  128. UpdateData();
  129. SetModified();
  130. }
  131. void CTHMessagePage::OnButtonInsertion2()
  132. {
  133. CPoint pt;
  134. GetCursorPos(&pt);
  135. m_InsertionMenu2.DisplayMenu(pt);
  136. UpdateData();
  137. SetModified();
  138. }
  139. void CTHMessagePage::OnChangeEditId()
  140. {
  141. // TODO: If this is a RICHEDIT control, the control will not
  142. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  143. // function and call CRichEditCtrl().SetEventMask()
  144. // with the ENM_CHANGE flag ORed into the mask.
  145. SetModified(TRUE);
  146. }