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.

138 lines
3.9 KiB

  1. // pgthread.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "regtrace.h"
  5. #include "pgthread.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char BASED_CODE THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CRegThreadPage property page
  12. IMPLEMENT_DYNCREATE(CRegThreadPage, CRegPropertyPage)
  13. CRegThreadPage::CRegThreadPage() : CRegPropertyPage(CRegThreadPage::IDD)
  14. {
  15. //{{AFX_DATA_INIT(CRegThreadPage)
  16. m_fAsyncTrace = TRUE;
  17. //}}AFX_DATA_INIT
  18. m_nThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
  19. }
  20. CRegThreadPage::~CRegThreadPage()
  21. {
  22. }
  23. void CRegThreadPage::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CPropertyPage::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CRegThreadPage)
  27. DDX_Control(pDX, IDC_ASYNC, m_AsyncTrace);
  28. DDX_Check(pDX, IDC_ASYNC, m_fAsyncTrace);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CRegThreadPage, CPropertyPage)
  32. //{{AFX_MSG_MAP(CRegThreadPage)
  33. ON_BN_CLICKED(IDC_PRIORITY_ABOVE, OnPriorityClick)
  34. ON_BN_CLICKED(IDC_PRIORITY_BELOW, OnPriorityClick)
  35. ON_BN_CLICKED(IDC_PRIORITY_HIGHEST, OnPriorityClick)
  36. ON_BN_CLICKED(IDC_PRIORITY_IDLE, OnPriorityClick)
  37. ON_BN_CLICKED(IDC_PRIORITY_NORMAL, OnPriorityClick)
  38. ON_BN_CLICKED(IDC_ASYNC, OnAsync)
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. BOOL CRegThreadPage::InitializePage()
  42. {
  43. if ( !App.GetTraceRegDword( "AsyncThreadPriority", (LPDWORD)&m_nThreadPriority ) )
  44. {
  45. m_nThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
  46. App.SetTraceRegDword( "AsyncThreadPriority", m_nThreadPriority );
  47. }
  48. if ( !App.GetTraceRegDword( "AsyncTraceFlag", (LPDWORD)&m_fAsyncTrace ) )
  49. {
  50. m_fAsyncTrace = TRUE;
  51. App.SetTraceRegDword( "AsyncTraceFlag", m_fAsyncTrace );
  52. }
  53. return TRUE;
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CRegThreadPage message handlers
  57. BOOL CRegThreadPage::OnInitDialog()
  58. {
  59. int nID;
  60. CPropertyPage::OnInitDialog();
  61. switch( m_nThreadPriority )
  62. {
  63. case THREAD_PRIORITY_HIGHEST: nID = IDC_PRIORITY_HIGHEST; break;
  64. case THREAD_PRIORITY_ABOVE_NORMAL: nID = IDC_PRIORITY_ABOVE; break;
  65. case THREAD_PRIORITY_NORMAL: nID = IDC_PRIORITY_NORMAL; break;
  66. case THREAD_PRIORITY_BELOW_NORMAL: nID = IDC_PRIORITY_BELOW; break;
  67. case THREAD_PRIORITY_IDLE: nID = IDC_PRIORITY_IDLE; break;
  68. default: nID = IDC_PRIORITY_BELOW; break;
  69. }
  70. CheckRadioButton( IDC_PRIORITY_HIGHEST, IDC_PRIORITY_IDLE, nID );
  71. OnAsync();
  72. SetModified( FALSE );
  73. return TRUE; // return TRUE unless you set the focus to a control
  74. // EXCEPTION: OCX Property Pages should return FALSE
  75. }
  76. void CRegThreadPage::OnPriorityClick()
  77. {
  78. int nSelectedID = GetCheckedRadioButton( IDC_PRIORITY_HIGHEST, IDC_PRIORITY_IDLE );
  79. switch( nSelectedID )
  80. {
  81. case IDC_PRIORITY_HIGHEST: m_nThreadPriority = THREAD_PRIORITY_HIGHEST; break;
  82. case IDC_PRIORITY_ABOVE: m_nThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL; break;
  83. case IDC_PRIORITY_NORMAL: m_nThreadPriority = THREAD_PRIORITY_NORMAL; break;
  84. case IDC_PRIORITY_BELOW: m_nThreadPriority = THREAD_PRIORITY_BELOW_NORMAL; break;
  85. case IDC_PRIORITY_IDLE: m_nThreadPriority = THREAD_PRIORITY_IDLE; break;
  86. default:
  87. ASSERT( FALSE );
  88. break;
  89. }
  90. SetModified( TRUE );
  91. }
  92. void CRegThreadPage::OnAsync()
  93. {
  94. BOOL m_fAsyncTrace = m_AsyncTrace.GetCheck() == 1;
  95. GetDlgItem( IDC_THREADGRP )->EnableWindow( m_fAsyncTrace );
  96. GetDlgItem( IDC_PRIORITY_HIGHEST )->EnableWindow( m_fAsyncTrace );
  97. GetDlgItem( IDC_PRIORITY_ABOVE )->EnableWindow( m_fAsyncTrace );
  98. GetDlgItem( IDC_PRIORITY_NORMAL )->EnableWindow( m_fAsyncTrace );
  99. GetDlgItem( IDC_PRIORITY_BELOW )->EnableWindow( m_fAsyncTrace );
  100. GetDlgItem( IDC_PRIORITY_IDLE )->EnableWindow( m_fAsyncTrace );
  101. SetModified( TRUE );
  102. }
  103. void CRegThreadPage::OnOK()
  104. {
  105. App.SetTraceRegDword( "AsyncThreadPriority", m_nThreadPriority );
  106. App.SetTraceRegDword( "AsyncTraceFlag", m_fAsyncTrace );
  107. SetModified( FALSE );
  108. }