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.

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