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.

186 lines
5.4 KiB

  1. // ActionNtEventLogPage.cpp : implementation file
  2. //
  3. // 03/05/00 v-marfin bug 59643 : Make this the default starting page.
  4. // 04/04/00 v-marfin bug 62880 : fix for help link
  5. #include "stdafx.h"
  6. #include "snapin.h"
  7. #include "ActionNtEventLogPage.h"
  8. #include "Action.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CActionNtEventLogPage property page
  16. IMPLEMENT_DYNCREATE(CActionNtEventLogPage, CHMPropertyPage)
  17. CActionNtEventLogPage::CActionNtEventLogPage() : CHMPropertyPage(CActionNtEventLogPage::IDD)
  18. {
  19. //{{AFX_DATA_INIT(CActionNtEventLogPage)
  20. m_sEventText = _T("");
  21. m_sEventType = _T("");
  22. m_iEventID = 0;
  23. //}}AFX_DATA_INIT
  24. m_sHelpTopic = _T("HMon21.chm::/dNTevact.htm"); // v-marfin 62880
  25. }
  26. CActionNtEventLogPage::~CActionNtEventLogPage()
  27. {
  28. }
  29. void CActionNtEventLogPage::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CHMPropertyPage::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CActionNtEventLogPage)
  33. DDX_Control(pDX, IDC_EDIT_EVENT_TEXT, m_TextWnd);
  34. DDX_Control(pDX, IDC_COMBO_EVENT_TYPE, m_EventType);
  35. DDX_Text(pDX, IDC_EDIT_EVENT_TEXT, m_sEventText);
  36. DDX_CBString(pDX, IDC_COMBO_EVENT_TYPE, m_sEventType);
  37. DDX_Text(pDX, IDC_EDIT_EVENT_ID, m_iEventID);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CActionNtEventLogPage, CHMPropertyPage)
  41. //{{AFX_MSG_MAP(CActionNtEventLogPage)
  42. ON_CBN_SELENDOK(IDC_COMBO_EVENT_TYPE, OnSelendokComboEventType)
  43. ON_EN_CHANGE(IDC_EDIT_EVENT_ID, OnChangeEditEventId)
  44. ON_EN_CHANGE(IDC_EDIT_EVENT_TEXT, OnChangeEditEventText)
  45. ON_BN_CLICKED(IDC_BUTTON_INSERTION, OnButtonInsertion)
  46. ON_WM_DESTROY()
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CActionNtEventLogPage message handlers
  51. BOOL CActionNtEventLogPage::OnInitDialog()
  52. {
  53. // v-marfin : bug 59643 : This will be the default starting page for the property
  54. // sheet so call CnxPropertyPageCreate() to unmarshal the
  55. // connection for this thread. This function must be called
  56. // by the first page of the property sheet. It used to
  57. // be called by the "General" page and its call still remains
  58. // there as well in case the general page is loaded by a
  59. // different code path that does not also load this page.
  60. // The CnxPropertyPageCreate function has been safeguarded
  61. // to simply return if the required call has already been made.
  62. // CnxPropertyPageDestory() must be called from this page's
  63. // OnDestroy function.
  64. // unmarshal connmgr
  65. CnxPropertyPageCreate();
  66. CHMPropertyPage::OnInitDialog();
  67. if( ! m_InsertionMenu.Create(&m_TextWnd,GetObjectPtr(),false) )
  68. {
  69. GetDlgItem(IDC_BUTTON_INSERTION)->EnableWindow(FALSE);
  70. }
  71. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  72. if( pConsumerObject )
  73. {
  74. int iEventType = 0;
  75. pConsumerObject->GetProperty(_T("EventType"),iEventType);
  76. m_EventType.SetCurSel(iEventType);
  77. pConsumerObject->GetProperty(_T("EventID"),m_iEventID);
  78. CStringArray saStrings;
  79. pConsumerObject->GetProperty(_T("InsertionStringTemplates"),saStrings);
  80. if( saStrings.GetSize() )
  81. {
  82. m_sEventText = saStrings[0];
  83. }
  84. delete pConsumerObject;
  85. }
  86. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,9999);
  87. UpdateData(FALSE);
  88. return TRUE; // return TRUE unless you set the focus to a control
  89. // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91. BOOL CActionNtEventLogPage::OnApply()
  92. {
  93. if( ! CHMPropertyPage::OnApply() )
  94. {
  95. return FALSE;
  96. }
  97. UpdateData();
  98. CWbemClassObject* pConsumerObject = ((CAction*)GetObjectPtr())->GetConsumerClassObject();
  99. if( pConsumerObject )
  100. {
  101. int iEventType = m_EventType.GetCurSel();
  102. pConsumerObject->SetProperty(_T("EventType"),iEventType);
  103. pConsumerObject->SetProperty(_T("EventID"),m_iEventID);
  104. CStringArray saStrings;
  105. saStrings.Add(m_sEventText);
  106. pConsumerObject->SetProperty(_T("InsertionStringTemplates"),saStrings);
  107. pConsumerObject->SetProperty(_T("NumberOfInsertionStrings"),1);
  108. pConsumerObject->SaveAllProperties();
  109. delete pConsumerObject;
  110. }
  111. SetModified(FALSE);
  112. return TRUE;
  113. }
  114. void CActionNtEventLogPage::OnSelendokComboEventType()
  115. {
  116. SetModified();
  117. }
  118. void CActionNtEventLogPage::OnChangeEditEventId()
  119. {
  120. // TODO: If this is a RICHEDIT control, the control will not
  121. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  122. // function and call CRichEditCtrl().SetEventMask()
  123. // with the ENM_CHANGE flag ORed into the mask.
  124. SetModified();
  125. }
  126. void CActionNtEventLogPage::OnChangeEditEventText()
  127. {
  128. // TODO: If this is a RICHEDIT control, the control will not
  129. // send this notification unless you override the CHMPropertyPage::OnInitDialog()
  130. // function and call CRichEditCtrl().SetEventMask()
  131. // with the ENM_CHANGE flag ORed into the mask.
  132. SetModified();
  133. }
  134. void CActionNtEventLogPage::OnButtonInsertion()
  135. {
  136. CPoint pt;
  137. GetCursorPos(&pt);
  138. m_InsertionMenu.DisplayMenu(pt);
  139. UpdateData();
  140. SetModified();
  141. }
  142. void CActionNtEventLogPage::OnDestroy()
  143. {
  144. CHMPropertyPage::OnDestroy();
  145. // v-marfin : bug 59643 : CnxPropertyPageDestory() must be called from this page's
  146. // OnDestroy function.
  147. CnxPropertyPageDestroy();
  148. }