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.

193 lines
4.5 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. Logwarnd.cpp
  5. Abstract:
  6. Implementation of the Log Type mismatch warning dialog.
  7. --*/
  8. #include "stdafx.h"
  9. #include "smlogcfg.h"
  10. #include "smtraceq.h"
  11. #include "provprop.h"
  12. #include "logwarnd.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. static ULONG
  19. s_aulHelpIds[] =
  20. {
  21. IDC_LWARN_CHECK_NO_MORE_LOG_TYPE, IDH_CHECK_NO_MORE,
  22. 0,0
  23. };
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CLogwarnd dialog
  26. CLogWarnd::CLogWarnd(CWnd* pParent /*=NULL*/)
  27. : CDialog(CLogWarnd::IDD, pParent)
  28. {
  29. //{{AFX_DATA_INIT(CLogWarnd)
  30. m_CheckNoMore = FALSE;
  31. m_ErrorMsg = 0 ;
  32. m_dwLogType = 0L;
  33. //}}AFX_DATA_INIT
  34. }
  35. void CLogWarnd::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CLogWarnd)
  39. DDX_Check(pDX, IDC_LWARN_CHECK_NO_MORE_LOG_TYPE, m_CheckNoMore);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CLogWarnd, CDialog)
  43. //{{AFX_MSG_MAP(CLogWarnd)
  44. ON_BN_CLICKED(IDC_LWARN_CHECK_NO_MORE_LOG_TYPE,OnCheckNoMoreLogType)
  45. ON_WM_HELPINFO()
  46. ON_WM_CONTEXTMENU()
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CLogWarnd message handlers
  51. void
  52. CLogWarnd::OnOK()
  53. {
  54. UpdateData(TRUE);
  55. if (m_CheckNoMore) {
  56. long nErr;
  57. HKEY hKey;
  58. DWORD dwWarnFlag;
  59. DWORD dwDataSize;
  60. DWORD dwDisposition;
  61. TCHAR RegValName[MAX_PATH];
  62. hKey = m_hKey;
  63. dwWarnFlag = m_CheckNoMore;
  64. switch (m_dwLogType){
  65. case SLQ_COUNTER_LOG:
  66. _stprintf(RegValName, _T("NoWarnCounterLog"));
  67. break;
  68. case SLQ_ALERT:
  69. _stprintf(RegValName, _T("NoWarnAlertLog"));
  70. break;
  71. }
  72. nErr = RegCreateKeyEx( HKEY_CURRENT_USER,
  73. _T("Software\\Microsoft\\PerformanceLogsAndAlerts"),
  74. 0,
  75. _T("REG_DWORD"),
  76. REG_OPTION_NON_VOLATILE,
  77. KEY_ALL_ACCESS,
  78. NULL,
  79. &hKey,
  80. &dwDisposition);
  81. if( nErr == ERROR_SUCCESS ) {
  82. dwDataSize = sizeof(DWORD);
  83. nErr = RegSetValueEx(hKey,
  84. RegValName,
  85. NULL,
  86. REG_DWORD,
  87. (LPBYTE) &dwWarnFlag,
  88. dwDataSize
  89. );
  90. if( ERROR_SUCCESS != nErr )
  91. DisplayError( GetLastError(), _T("Close PerfLog User Key failed") );
  92. }
  93. }
  94. CDialog::OnOK();
  95. }
  96. BOOL
  97. CLogWarnd::OnInitDialog()
  98. {
  99. CString cstrMessage , cstrWrongLog;
  100. SetWindowText ( m_strTitle );
  101. switch (m_dwLogType){
  102. case SLQ_COUNTER_LOG:
  103. cstrWrongLog.LoadString(IDS_COUNTER_LOG) ;
  104. break;
  105. case SLQ_ALERT:
  106. cstrWrongLog.LoadString(IDS_ALERT_LOG);
  107. break;
  108. case SMONCTRL_LOG:
  109. cstrWrongLog.LoadString( IDS_SMCTRL_LOG );
  110. break;
  111. default:
  112. cstrWrongLog.Format(L"");
  113. break;
  114. }
  115. switch(m_ErrorMsg){
  116. case ID_ERROR_COUNTER_LOG:
  117. cstrMessage.Format(IDS_ERRMSG_COUNTER_LOG,cstrWrongLog );
  118. break;
  119. case ID_ERROR_ALERT_LOG:
  120. cstrMessage.Format(IDS_ERRMSG_ALERT_LOG,cstrWrongLog);
  121. break;
  122. case ID_ERROR_TRACE_LOG:
  123. cstrMessage.Format(IDS_ERRMSG_TRACE_LOG,cstrWrongLog);
  124. break;
  125. case ID_ERROR_SMONCTRL_LOG:
  126. cstrMessage.Format(IDS_ERRMSG_SMCTRL_LOG,cstrWrongLog);
  127. break;
  128. }
  129. ::SetWindowText((GetDlgItem(IDC_LWARN_MSG_WARN))->m_hWnd, cstrMessage);
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. // EXCEPTION: OCX Property Pages should return FALSE
  132. }
  133. VOID
  134. CLogWarnd::OnCheckNoMoreLogType()
  135. {
  136. }
  137. BOOL
  138. CLogWarnd::OnHelpInfo(HELPINFO* pHelpInfo)
  139. {
  140. if ( pHelpInfo->iCtrlId >= IDC_LWARN_FIRST_HELP_CTRL_ID ) {
  141. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_strContextHelpFile, s_aulHelpIds);
  142. }
  143. return TRUE;
  144. }
  145. void
  146. CLogWarnd::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  147. {
  148. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)(pWnd->m_hWnd), NULL, m_strContextHelpFile, s_aulHelpIds);
  149. return;
  150. }