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.

126 lines
3.1 KiB

  1. /****************************************************************************
  2. Copyright (c) Microsoft Corporation 1998
  3. All rights reserved
  4. File: ERRORLOG.CPP
  5. ***************************************************************************/
  6. #include "pch.h"
  7. #include "utils.h"
  8. #include "logging.h"
  9. #include <richedit.h>
  10. DEFINE_MODULE("RIPREP");
  11. //
  12. // EditStreamCallback( )
  13. //
  14. // Callback routine used by the rich edit control to read in the log file.
  15. //
  16. // Returns: 0 - to continue.
  17. // Otherwize, Win32 error code.
  18. //
  19. DWORD CALLBACK
  20. EditStreamCallback (
  21. HANDLE hLogFile,
  22. LPBYTE Buffer,
  23. LONG cb,
  24. PULONG pcb
  25. )
  26. {
  27. DWORD error;
  28. UNREFERENCED_PARAMETER(hLogFile);
  29. TraceFunc( "EditStreamCallback( )\n" );
  30. if ( !ReadFile ( g_hLogFile, Buffer, cb, pcb, NULL ) ) {
  31. error = GetLastError( );
  32. DebugMsg( "Error - EditStreamCallback: GetLastError() => 0x%08x \n", error );
  33. RETURN(error);
  34. }
  35. RETURN(0);
  36. }
  37. //
  38. // ErrorsDlgProc()
  39. //
  40. INT_PTR CALLBACK
  41. ErrorsDlgProc(
  42. HWND hDlg,
  43. UINT uMsg,
  44. WPARAM wParam,
  45. LPARAM lParam )
  46. {
  47. UNREFERENCED_PARAMETER(wParam);
  48. UNREFERENCED_PARAMETER(lParam);
  49. switch (uMsg)
  50. {
  51. default:
  52. return FALSE;
  53. case WM_INITDIALOG:
  54. {
  55. HRESULT hr;
  56. HWND hWndRichEdit = GetDlgItem( hDlg, IDC_E_ERRORS );
  57. EDITSTREAM eStream; // structure used by EM_STREAMIN message
  58. Assert( hWndRichEdit );
  59. ZeroMemory( &eStream, sizeof(eStream) );
  60. hr = THR( LogOpen( ) );
  61. if ( FAILED( hr ) )
  62. {
  63. HWND hParent = GetParent( hDlg );
  64. DestroyWindow( hDlg );
  65. SetFocus( hParent );
  66. return FALSE;
  67. }
  68. // move to the beginning of the newest log
  69. SetFilePointer( g_hLogFile, g_dwLogFileStartLow, (LONG*)&g_dwLogFileStartHigh, FILE_BEGIN );
  70. eStream.pfnCallback = (EDITSTREAMCALLBACK) EditStreamCallback;
  71. SendMessage ( hWndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM) &eStream );
  72. SendMessage ( hWndRichEdit, EM_SETMODIFY, TRUE, 0 );
  73. CloseHandle( g_hLogFile );
  74. g_hLogFile = INVALID_HANDLE_VALUE;
  75. LogClose( );
  76. CenterDialog( hDlg );
  77. PostMessage( hDlg, WM_USER, 0, 0 );
  78. }
  79. break;
  80. case WM_COMMAND:
  81. switch ( wParam )
  82. {
  83. case IDCANCEL:
  84. EndDialog ( hDlg, 0 );
  85. break;
  86. default:
  87. return FALSE;
  88. }
  89. case WM_USER:
  90. {
  91. HWND hWndRichEdit = GetDlgItem( hDlg, IDC_E_ERRORS );
  92. // These have to be delayed or the Edit control will
  93. // highlight all the text.
  94. SendMessage(hWndRichEdit,EM_SETSEL,0,0);
  95. SendMessage(hWndRichEdit,EM_SCROLLCARET,0,0);
  96. }
  97. break;
  98. }
  99. return TRUE;
  100. }