Leaked source code of windows server 2003
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.

235 lines
7.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // LogSessionOutputOptionDlg.cpp : implementation file
  6. //////////////////////////////////////////////////////////////////////////////
  7. #include "stdafx.h"
  8. #include <tchar.h>
  9. #include <wmistr.h>
  10. #include <initguid.h>
  11. extern "C" {
  12. #include <evntrace.h>
  13. }
  14. #include <traceprt.h>
  15. #include "TraceView.h"
  16. #include "resource.h"
  17. #include "logsession.h"
  18. #include "DisplayDlg.h"
  19. #include "logDisplayOptionDlg.h"
  20. #include "LogSessionInformationDlg.h"
  21. #include "ProviderSetupDlg.h"
  22. #include "LogSessionPropSht.h"
  23. #include "LogSessionOutputOptionDlg.h"
  24. #include "LogSessionAdvPropSht.h"
  25. // CLogSessionOutputOptionDlg dialog
  26. IMPLEMENT_DYNAMIC(CLogSessionOutputOptionDlg, CPropertyPage)
  27. CLogSessionOutputOptionDlg::CLogSessionOutputOptionDlg()
  28. : CPropertyPage(CLogSessionOutputOptionDlg::IDD)
  29. {
  30. }
  31. CLogSessionOutputOptionDlg::~CLogSessionOutputOptionDlg()
  32. {
  33. }
  34. BOOL CLogSessionOutputOptionDlg::OnInitDialog()
  35. {
  36. BOOL retVal;
  37. CLogSessionAdvPropSht *pSheet = (CLogSessionAdvPropSht *)GetParent();
  38. //
  39. // Determine if the log session is actively tracing
  40. //
  41. m_bTraceActive = pSheet->m_pLogSession->m_bTraceActive;
  42. //
  43. // Determine enable state of controls
  44. //
  45. m_bWriteListingFile = pSheet->m_pLogSessionPropSht->m_bWriteListingFile;
  46. m_bWriteSummaryFile = pSheet->m_pLogSessionPropSht->m_bWriteSummaryFile;
  47. retVal = CPropertyPage::OnInitDialog();
  48. m_listingFileName.SetWindowText(pSheet->m_pLogSessionPropSht->m_listingFileName);
  49. m_summaryFileName.SetWindowText(pSheet->m_pLogSessionPropSht->m_summaryFileName);
  50. //
  51. // setup listing file controls
  52. //
  53. //
  54. // set the check
  55. //
  56. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->SetCheck(m_bWriteListingFile);
  57. //
  58. // enable the check
  59. //
  60. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->EnableWindow(!m_bTraceActive);
  61. //
  62. // enable the edit and browse controls
  63. //
  64. ((CEdit *)GetDlgItem(IDC_LISTING_FILE_EDIT))->EnableWindow(
  65. m_bWriteListingFile && !m_bTraceActive);
  66. ((CButton *)GetDlgItem(IDC_LISTING_BROWSE_BUTTON))->EnableWindow(
  67. m_bWriteListingFile && !m_bTraceActive);
  68. //
  69. // setup summary file controls
  70. //
  71. //
  72. // set the check
  73. //
  74. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->SetCheck(m_bWriteSummaryFile);
  75. //
  76. // enable the check
  77. //
  78. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->EnableWindow(!m_bTraceActive);
  79. //
  80. // enable the edit and browse controls
  81. //
  82. ((CEdit *)GetDlgItem(IDC_SUMMARY_FILE_EDIT))->EnableWindow(
  83. m_bWriteSummaryFile && !m_bTraceActive);
  84. ((CButton *)GetDlgItem(IDC_SUMMARY_BROWSE_BUTTON))->EnableWindow(
  85. m_bWriteSummaryFile && !m_bTraceActive);
  86. return retVal;
  87. }
  88. BOOL CLogSessionOutputOptionDlg::OnSetActive()
  89. {
  90. //
  91. // Enable the correct wizard buttons
  92. //
  93. //
  94. // check boxes
  95. //
  96. ((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->EnableWindow(!m_bTraceActive);
  97. ((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->EnableWindow(!m_bTraceActive);
  98. //
  99. // edit controls
  100. //
  101. ((CEdit *)GetDlgItem(IDC_LISTING_FILE_EDIT))->EnableWindow(!m_bTraceActive && m_bWriteListingFile);
  102. ((CEdit *)GetDlgItem(IDC_SUMMARY_FILE_EDIT))->EnableWindow(!m_bTraceActive && m_bWriteSummaryFile);
  103. //
  104. // browse buttons
  105. //
  106. ((CButton *)GetDlgItem(IDC_LISTING_BROWSE_BUTTON))->EnableWindow(!m_bTraceActive && m_bWriteListingFile);
  107. ((CButton *)GetDlgItem(IDC_SUMMARY_BROWSE_BUTTON))->EnableWindow(!m_bTraceActive && m_bWriteSummaryFile);
  108. return CPropertyPage::OnSetActive();
  109. }
  110. void CLogSessionOutputOptionDlg::DoDataExchange(CDataExchange* pDX)
  111. {
  112. CPropertyPage::DoDataExchange(pDX);
  113. DDX_Control(pDX, IDC_LISTING_FILE_EDIT, m_listingFileName);
  114. DDX_Control(pDX, IDC_SUMMARY_FILE_EDIT, m_summaryFileName);
  115. }
  116. BEGIN_MESSAGE_MAP(CLogSessionOutputOptionDlg, CPropertyPage)
  117. ON_BN_CLICKED(IDC_LISTING_FILE_CHECK, OnBnClickedListingFileCheck)
  118. ON_BN_CLICKED(IDC_SUMMARY_FILE_CHECK, OnBnClickedSummaryFileCheck)
  119. ON_BN_CLICKED(IDC_LISTING_BROWSE_BUTTON, OnBnClickedListingBrowseButton)
  120. ON_BN_CLICKED(IDC_SUMMARY_BROWSE_BUTTON, OnBnClickedSummaryBrowseButton)
  121. END_MESSAGE_MAP()
  122. // CLogSessionOutputOptionDlg message handlers
  123. void CLogSessionOutputOptionDlg::OnBnClickedListingFileCheck()
  124. {
  125. if(((CButton *)GetDlgItem(IDC_LISTING_FILE_CHECK))->GetCheck()) {
  126. GetDlgItem(IDC_LISTING_FILE_EDIT)->EnableWindow(TRUE);
  127. GetDlgItem(IDC_LISTING_BROWSE_BUTTON)->EnableWindow(TRUE);
  128. m_bWriteListingFile = TRUE;
  129. } else {
  130. GetDlgItem(IDC_LISTING_FILE_EDIT)->EnableWindow(FALSE);
  131. GetDlgItem(IDC_LISTING_BROWSE_BUTTON)->EnableWindow(FALSE);
  132. m_bWriteListingFile = FALSE;
  133. }
  134. }
  135. void CLogSessionOutputOptionDlg::OnBnClickedSummaryFileCheck()
  136. {
  137. if(((CButton *)GetDlgItem(IDC_SUMMARY_FILE_CHECK))->GetCheck()) {
  138. GetDlgItem(IDC_SUMMARY_FILE_EDIT)->EnableWindow(TRUE);
  139. GetDlgItem(IDC_SUMMARY_BROWSE_BUTTON)->EnableWindow(TRUE);
  140. m_bWriteSummaryFile = TRUE;
  141. } else {
  142. GetDlgItem(IDC_SUMMARY_FILE_EDIT)->EnableWindow(FALSE);
  143. GetDlgItem(IDC_SUMMARY_BROWSE_BUTTON)->EnableWindow(FALSE);
  144. m_bWriteSummaryFile = FALSE;
  145. }
  146. }
  147. void CLogSessionOutputOptionDlg::OnBnClickedListingBrowseButton()
  148. {
  149. //
  150. // Use the common controls file open dialog
  151. //
  152. CFileDialog fileDlg(TRUE,
  153. _T("out"),_T("*.out"),
  154. OFN_CREATEPROMPT | OFN_HIDEREADONLY |
  155. OFN_EXPLORER | OFN_NOCHANGEDIR,
  156. _T("Output Files (*.out)|*.out|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"),
  157. this);
  158. //
  159. // Pop the dialog... Any error, just return
  160. //
  161. if( fileDlg.DoModal()!=IDOK ) {
  162. return;
  163. }
  164. //
  165. // Get the file name and display it
  166. //
  167. if(!fileDlg.GetPathName().IsEmpty()) {
  168. m_listingFileName.SetWindowText(fileDlg.GetPathName());
  169. m_listingFileName.SetFocus();
  170. }
  171. }
  172. void CLogSessionOutputOptionDlg::OnBnClickedSummaryBrowseButton()
  173. {
  174. //
  175. // Use the common controls file open dialog
  176. //
  177. CFileDialog fileDlg(TRUE,
  178. _T("sum"),_T("*.sum"),
  179. OFN_CREATEPROMPT | OFN_HIDEREADONLY |
  180. OFN_EXPLORER | OFN_NOCHANGEDIR,
  181. _T("Summary Files (*.sum)|*.sum|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"),
  182. this);
  183. //
  184. // Pop the dialog... Any error, just return
  185. //
  186. if( fileDlg.DoModal()!=IDOK ) {
  187. return;
  188. }
  189. //
  190. // Get the file name and display it
  191. //
  192. if(!fileDlg.GetPathName().IsEmpty()) {
  193. m_summaryFileName.SetWindowText(fileDlg.GetPathName());
  194. m_summaryFileName.SetFocus();
  195. }
  196. }