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.

234 lines
5.7 KiB

  1. //******************************************************************
  2. // source.cpp
  3. //
  4. // This is file contains the implementation of the CSource class.
  5. //
  6. // The CSource class acts as a container class for the message source,
  7. // which is composed of the source tree control and the message list.
  8. //
  9. // Author: Larry A. French
  10. //
  11. // History:
  12. // 20-Febuary-1996 Larry A. French
  13. // Wrote it.
  14. //
  15. //
  16. // Copyright (C) 1995, 1996 Microsoft Corporation. All rights reserved.
  17. //******************************************************************
  18. #include "stdafx.h"
  19. #include "regkey.h"
  20. #include "source.h"
  21. #include "utils.h"
  22. #include "globals.h"
  23. #include "tcsource.h"
  24. #include "lcsource.h"
  25. #include "evntfind.h"
  26. #include "trapdlg.h"
  27. CSource::CSource()
  28. {
  29. m_pEventSource = NULL;
  30. m_ptcSource = NULL;
  31. m_plcSource = NULL;
  32. m_pdlgEventTrap = NULL;
  33. m_pdlgFind = NULL;
  34. }
  35. CSource::~CSource()
  36. {
  37. delete m_pdlgFind;
  38. }
  39. SCODE CSource::Create(CEventTrapDlg* pdlgEventTrap)
  40. {
  41. m_ptcSource = &pdlgEventTrap->m_tcSource;
  42. m_ptcSource->m_pSource = this;
  43. m_plcSource = &pdlgEventTrap->m_lcSource;
  44. m_plcSource->m_pSource = this;
  45. m_pdlgEventTrap = pdlgEventTrap;
  46. return S_OK;
  47. }
  48. //***************************************************************************
  49. // CSource::NotifyTcSelChanged
  50. //
  51. // This method returns an array of pointers to the messages currently selected
  52. // in the CLcEvents list control. These pointers are owned by g_aEventLogs and
  53. // the caller should not delete them.
  54. //
  55. // Parameters:
  56. // None.
  57. //
  58. // Returns:
  59. // Nothing.
  60. //
  61. //***************************************************************************
  62. void CSource::GetSelectedMessages(CXMessageArray& aMessages)
  63. {
  64. m_plcSource->GetSelectedMessages(aMessages);
  65. }
  66. //***************************************************************************
  67. // CSource::NotifyTcSelChanged
  68. //
  69. // This method is called when the selection changes in the event-source tree
  70. // control (CTcSource). When the selection changes, the message list must
  71. // be updated.
  72. //
  73. // Parameters:
  74. // None.
  75. //
  76. // Returns:
  77. // Nothing.
  78. //
  79. //***************************************************************************
  80. void CSource::NotifyTcSelChanged()
  81. {
  82. m_pEventSource = m_ptcSource->GetSelectedEventSource();
  83. m_plcSource->SetEventSource(m_pEventSource);
  84. m_pdlgEventTrap->NotifySourceSelChanged();
  85. }
  86. //***************************************************************************
  87. //
  88. // CSource::CreateWindowEpilogue()
  89. //
  90. // This method is called after a window has been created for this list
  91. // control. Final initialization is done here.
  92. //
  93. // Parameters:
  94. // None.
  95. //
  96. // Returns:
  97. // SCODE
  98. // S_OK if the initialization was successful, otherwise E_FAIL.
  99. //
  100. // Status:
  101. //
  102. //***************************************************************************
  103. SCODE CSource::CreateWindowEpilogue()
  104. {
  105. SCODE scTc = m_ptcSource->CreateWindowEpilogue();
  106. SCODE scLc = m_plcSource->CreateWindowEpilogue();
  107. if (FAILED(scTc) || FAILED(scLc)) {
  108. return E_FAIL;
  109. }
  110. return S_OK;
  111. }
  112. //******************************************************************
  113. // CSource::Find
  114. //
  115. // Find the specified event source. This is done by searching either
  116. // the tree or the list control depending on the bSearchTree parameter.
  117. //
  118. // Parameters:
  119. // BOOL bSearchTree
  120. // TRUE if the tree should be searched, otherwise the list control
  121. // is searched.
  122. //
  123. // CString& sText
  124. // A string containing the text to search for.
  125. //
  126. // BOOL bWholeWord
  127. // TRUE if this is a "whole word" search. False if it
  128. // is OK to match a partial word.
  129. //
  130. // BOOL bMatchCase
  131. // TRUE if a case-sensitive comparison should be used.
  132. //
  133. // Returns:
  134. // BOOL
  135. // TRUE if the string was found, FALSE otherwise. If the specified
  136. // text is found, then the selection is set on the corresponding
  137. // item, the item is scrolled into view and the focus
  138. // is set on the item.
  139. //
  140. //******************************************************************
  141. BOOL CSource::Find(BOOL bSearchTree, CString sText, BOOL bWholeWord, BOOL bMatchCase)
  142. {
  143. if (bSearchTree)
  144. return m_ptcSource->Find(sText, bWholeWord, bMatchCase);
  145. else
  146. return m_plcSource->Find(sText, bWholeWord, bMatchCase);
  147. }
  148. //************************************************************************
  149. // CSource::OnFind
  150. //
  151. // This method is called when the "Find" button in the CEventTrap dialog
  152. // is clicked.
  153. //
  154. // Parameters:
  155. // CWnd* pwndParent
  156. // Pointer to the parent window of the "find" dialog. This happens
  157. // to be the CEventTrapDialog.
  158. //
  159. // Returns:
  160. // Nothing.
  161. //
  162. //*************************************************************************
  163. void CSource::OnFind(CWnd* pwndParent)
  164. {
  165. if (m_pdlgFind == NULL) {
  166. m_pdlgFind = new CEventFindDlg(pwndParent);
  167. m_pdlgFind->Create(this, IDD_EVENTFINDDLG, pwndParent);
  168. }
  169. m_pdlgFind->BringWindowToTop();
  170. }
  171. //*************************************************************************
  172. // CSource::NotifyTrappingChange
  173. //
  174. // This method is called when an event is added or removed from the
  175. // event list. This CSource message source container must be notified
  176. // so that the corresponding method can be marked as trapped or not
  177. // trapped in the CLcSource list control.
  178. //
  179. // Parameters:
  180. // CXEventSource* pEventSource
  181. // Pointer to the event's event-source
  182. //
  183. // DWORD dwId
  184. // The event's ID
  185. //
  186. // BOOL bIsTrapping
  187. // TRUE if the event is being trapped, FALSE if not.,
  188. //
  189. // Returns:
  190. // Nothing.
  191. //*************************************************************************
  192. void CSource::NotifyTrappingChange(CXEventSource* pEventSource, DWORD dwId, BOOL bIsTrapping)
  193. {
  194. if (pEventSource == m_pEventSource) {
  195. m_plcSource->NotifyTrappingChange(dwId, bIsTrapping);
  196. }
  197. }