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.

153 lines
3.9 KiB

  1. // pgoutput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "regtrace.h"
  5. #include "pgoutput.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10. const DWORD MB = 1024 * 1024;
  11. const DWORD dwMinFileSize = 5; // in MB
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRegOutputPage property page
  14. IMPLEMENT_DYNCREATE(CRegOutputPage, CRegPropertyPage)
  15. CRegOutputPage::CRegOutputPage() : CRegPropertyPage(CRegOutputPage::IDD)
  16. {
  17. //{{AFX_DATA_INIT(CRegOutputPage)
  18. m_szFileName = _T("");
  19. m_dwMaxTraceFileSize = 0;
  20. //}}AFX_DATA_INIT
  21. m_dwOutputType = TRACE_OUTPUT_DISABLED;
  22. }
  23. CRegOutputPage::~CRegOutputPage()
  24. {
  25. }
  26. void CRegOutputPage::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CPropertyPage::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CRegOutputPage)
  30. DDX_Control(pDX, IDC_FILENAME, m_FileName);
  31. DDX_Text(pDX, IDC_FILENAME, m_szFileName);
  32. DDX_Text(pDX, IDC_MAXTRACEFILESIZE, m_dwMaxTraceFileSize);
  33. DDV_MinMaxDWord(pDX, m_dwMaxTraceFileSize, dwMinFileSize, 999);
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(CRegOutputPage, CPropertyPage)
  37. //{{AFX_MSG_MAP(CRegOutputPage)
  38. ON_BN_CLICKED(IDC_DEBUGGER, OnOutputClick)
  39. ON_EN_CHANGE(IDC_FILENAME, OnChangeFilename)
  40. ON_BN_CLICKED(IDC_DISABLED, OnOutputClick)
  41. ON_BN_CLICKED(IDC_DISCARD, OnOutputClick)
  42. ON_BN_CLICKED(IDC_FILE, OnOutputClick)
  43. ON_EN_CHANGE(IDC_MAXTRACEFILESIZE, OnChangeMaxTraceFileSize)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. BOOL CRegOutputPage::InitializePage()
  47. {
  48. if ( !App.GetTraceRegDword( "OutputTraceType", &m_dwOutputType ) )
  49. {
  50. m_dwOutputType = TRACE_OUTPUT_FILE;
  51. App.SetTraceRegDword( "OutputTraceType", m_dwOutputType );
  52. }
  53. if ( App.GetTraceRegDword( "MaxTraceFileSize", &m_dwMaxTraceFileSize ) &&
  54. m_dwMaxTraceFileSize > dwMinFileSize*MB)
  55. {
  56. m_dwMaxTraceFileSize = (m_dwMaxTraceFileSize + MB - 1) / MB;
  57. } else {
  58. m_dwMaxTraceFileSize = dwMinFileSize; // Default to 5mb
  59. App.SetTraceRegDword( "MaxTraceFileSize", m_dwMaxTraceFileSize * MB );
  60. }
  61. if ( !App.GetTraceRegString( "TraceFile", m_szFileName ) )
  62. {
  63. m_szFileName = "c:\\trace.atf";
  64. App.SetTraceRegString( "TraceFile", m_szFileName );
  65. }
  66. return TRUE;
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CRegOutputPage message handlers
  70. BOOL CRegOutputPage::OnInitDialog()
  71. {
  72. int nID;
  73. CPropertyPage::OnInitDialog();
  74. switch( m_dwOutputType )
  75. {
  76. case TRACE_OUTPUT_DISABLED: nID = IDC_DISABLED; break;
  77. case TRACE_OUTPUT_FILE: nID = IDC_FILE; break;
  78. case TRACE_OUTPUT_DEBUG: nID = IDC_DEBUGGER; break;
  79. case TRACE_OUTPUT_DISCARD: nID = IDC_DISCARD; break;
  80. default: nID = IDC_DISABLED; break;
  81. }
  82. CheckRadioButton( IDC_DISABLED, IDC_DISCARD, nID );
  83. OnOutputClick();
  84. SetModified( FALSE );
  85. return TRUE; // return TRUE unless you set the focus to a control
  86. // EXCEPTION: OCX Property Pages should return FALSE
  87. }
  88. void CRegOutputPage::OnOutputClick()
  89. {
  90. int nSelectedID = GetCheckedRadioButton( IDC_DISABLED, IDC_DISCARD );
  91. switch( nSelectedID )
  92. {
  93. case IDC_DISABLED: m_dwOutputType = TRACE_OUTPUT_DISABLED; break;
  94. case IDC_FILE: m_dwOutputType = TRACE_OUTPUT_FILE; break;
  95. case IDC_DEBUGGER: m_dwOutputType = TRACE_OUTPUT_DEBUG; break;
  96. case IDC_DISCARD: m_dwOutputType = TRACE_OUTPUT_DISCARD; break;
  97. default:
  98. ASSERT( FALSE );
  99. break;
  100. }
  101. m_FileName.EnableWindow( nSelectedID == IDC_FILE );
  102. SetModified( TRUE );
  103. }
  104. void CRegOutputPage::OnChangeFilename()
  105. {
  106. SetModified( TRUE );
  107. }
  108. void CRegOutputPage::OnOK()
  109. {
  110. App.SetTraceRegDword( "OutputTraceType", m_dwOutputType );
  111. App.SetTraceRegDword( "MaxTraceFileSize", m_dwMaxTraceFileSize * MB);
  112. App.SetTraceRegString( "TraceFile", m_szFileName );
  113. SetModified( FALSE );
  114. }
  115. void CRegOutputPage::OnChangeMaxTraceFileSize()
  116. {
  117. SetModified( TRUE );
  118. }