UI.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:21k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*++
  2. Copyright (c) 1993  Microsoft Corporation
  3. Module Name:
  4.     drwtsnui.c
  5. Abstract:
  6.     This function implements the ui (dialog) that controls the
  7.     options maintenace for drwatson.
  8. Author:
  9.     Wesley Witt (wesw) 1-May-1993
  10. Environment:
  11.     User Mode
  12. --*/
  13. #include <windows.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <mmsystem.h>
  18. #include <direct.h>
  19. #include <shellapi.h>
  20. #include "drwatson.h"
  21. #include "proto.h"
  22. #include "resource.h"
  23. void InitializeDialog( HWND hwnd );
  24. void InitializeCrashList( HWND hwnd );
  25. BOOL GetDialogValues( HWND hwnd );
  26. BOOL CALLBACK LogFileViewerDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  27. LRESULT DrWatsonWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  28. LPSTR ExpandPath(LPSTR lpPath);
  29. void
  30. DrWatsonWinMain( void )
  31. /*++
  32. Routine Description:
  33.     This is the entry point for DRWTSN32
  34. Arguments:
  35.     None.
  36. Return Value:
  37.     None.
  38. --*/
  39. {
  40.     HWND           hwnd;
  41.     MSG            msg;
  42.     WNDCLASS       wndclass;
  43.     HINSTANCE      hInst;
  44.     hInst                   = GetModuleHandle( NULL );
  45.     wndclass.style          = CS_HREDRAW | CS_VREDRAW;
  46.     wndclass.lpfnWndProc    = DrWatsonWndProc;
  47.     wndclass.cbClsExtra     = 0;
  48.     wndclass.cbWndExtra     = DLGWINDOWEXTRA;
  49.     wndclass.hInstance      = hInst;
  50.     wndclass.hIcon          = LoadIcon( hInst, MAKEINTRESOURCE(APPICON) );
  51.     wndclass.hCursor        = LoadCursor( NULL, IDC_ARROW );
  52.     wndclass.hbrBackground  = (HBRUSH) (COLOR_3DFACE + 1);
  53.     wndclass.lpszMenuName   = NULL;
  54.     wndclass.lpszClassName  = "DrWatsonDialog";
  55.     RegisterClass( &wndclass );
  56.     hwnd = CreateDialog( hInst,
  57.                          MAKEINTRESOURCE( DRWATSONDIALOG ),
  58.                          0,
  59.                          DrWatsonWndProc
  60.                        );
  61.     ShowWindow( hwnd, SW_SHOWNORMAL );
  62.     while (GetMessage (&msg, NULL, 0, 0)) {
  63.         if (!IsDialogMessage( hwnd, &msg )) {
  64.             TranslateMessage (&msg) ;
  65.             DispatchMessage (&msg) ;
  66.         }
  67.     }
  68.     return;
  69. }
  70. LRESULT
  71. DrWatsonWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  72. /*++
  73. Routine Description:
  74.     Window procedure for the DRWTSN32.EXE main user interface.
  75. Arguments:
  76.     hwnd       - window handle to the dialog box
  77.     message    - message number
  78.     wParam     - first message parameter
  79.     lParam     - second message parameter
  80. Return Value:
  81.     TRUE       - did not process the message
  82.     FALSE      - did process the message
  83. --*/
  84. {
  85.     DWORD    helpId;
  86.     UINT     Checked;
  87.     char     szCurrDir[MAX_PATH];
  88.     char     szWave[MAX_PATH];
  89.     char     szDump[MAX_PATH];
  90.     char     szHelpFileName[MAX_PATH];
  91.     LPSTR    p;
  92.     switch (message) {
  93.         case WM_CREATE:
  94.             return 0;
  95.         case WM_INITDIALOG:
  96.             SubclassControls( hwnd );
  97.             InitializeDialog( hwnd );
  98.             SetTimer( hwnd, 1, 50, NULL );
  99.             return 1;
  100.         case WM_TIMER:
  101.             if (GetKeyState(VK_F1) & 0x8000) {
  102.                 if ((GetFocus() != hwnd) && (GetParent(GetFocus()) != hwnd)) {
  103.                     return 0;
  104.                 }
  105.                 switch (GetDlgCtrlID( GetFocus() )) {
  106.                     case ID_LOGPATH:
  107.                         helpId = IDH_LOGFILELOCATION;
  108.                         break;
  109.                     case ID_BROWSE_LOGPATH:
  110.                         helpId = IDH_LOGFILELOCATION;
  111.                         break;
  112.                     case ID_WAVEFILE_TEXT:
  113.                         helpId = IDH_WAVEFILE;
  114.                         break;
  115.                     case ID_WAVE_FILE:
  116.                         helpId = IDH_WAVEFILE;
  117.                         break;
  118.                     case ID_BROWSE_WAVEFILE:
  119.                         helpId = IDH_WAVEFILE;
  120.                         break;
  121.                     case ID_TEST_WAVE:
  122.                         helpId = IDH_WAVEFILE;
  123.                         break;
  124.                     case ID_INSTRUCTIONS:
  125.                         helpId = IDH_NUMBEROFINSTR;
  126.                         break;
  127.                     case ID_NUM_CRASHES:
  128.                         helpId = IDH_NUMBEROFCRASHES;
  129.                         break;
  130.                     case ID_DUMPSYMBOLS:
  131.                         helpId = IDH_DUMPSYMBOLS;
  132.                         break;
  133.                     case ID_DUMPALLTHREADS:
  134.                         helpId = IDH_DUMPALLTHREADS;
  135.                         break;
  136.                     case ID_APPENDTOLOGFILE:
  137.                         helpId = IDH_APPENDTOLOGFILE;
  138.                         break;
  139.                     case ID_VISUAL:
  140.                         helpId = IDH_VISUAL;
  141.                         break;
  142.                     case ID_SOUND:
  143.                         helpId = IDH_SOUND;
  144.                         break;
  145.                     case ID_CRASHES:
  146.                         helpId = IDH_APPERRORS;
  147.                         break;
  148.                     case ID_LOGFILE_VIEW:
  149.                         helpId = IDH_VIEW;
  150.                         break;
  151.                     case ID_CLEAR:
  152.                         helpId = IDH_CLEAR;
  153.                         break;
  154.                     case ID_CRASH:
  155.                         helpId = IDH_CRASH;
  156.                         break;
  157.                     case ID_CRASH_DUMP:
  158.                         helpId = IDH_CRASH_DUMP;
  159.                         break;
  160.                     case IDOK:
  161.                         helpId = IDH_INDEX;
  162.                         break;
  163.                     case IDCANCEL:
  164.                         helpId = IDH_INDEX;
  165.                         break;
  166.                     case ID_HELP:
  167.                         helpId = IDH_INDEX;
  168.                         break;
  169.                     default:
  170.                         helpId = IDH_INDEX;
  171.                         break;
  172.                 }
  173.                 //
  174.                 // call winhelp
  175.                 //
  176.                 GetHelpFileName( szHelpFileName, sizeof(szHelpFileName ) );
  177.                 WinHelp( hwnd, szHelpFileName, HELP_FINDER, helpId );
  178.             }
  179.             return 1;
  180.         case WM_ACTIVATEAPP:
  181.         case WM_SETFOCUS:
  182.             SetFocusToCurrentControl();
  183.             return 0;
  184.         case WM_SYSCOMMAND:
  185.             if (wParam == ID_ABOUT) {
  186.                 char title[256];
  187.                 char extra[256];
  188.                 strcpy( title, LoadRcString( IDS_ABOUT_TITLE ) );
  189.                 strcpy( extra, LoadRcString( IDS_ABOUT_EXTRA ) );
  190.                 ShellAbout( hwnd,
  191.                             title,
  192.                             extra,
  193.                             LoadIcon( GetModuleHandle(NULL),
  194.                                       MAKEINTRESOURCE(APPICON)
  195.                                     )
  196.                           );
  197.                 return 0;
  198.             }
  199.             break;
  200.         case WM_COMMAND:
  201.             switch (wParam) {
  202.                 case IDOK:
  203.                     if (GetDialogValues( hwnd )) {
  204.                         PostQuitMessage( 0 );
  205.                     }
  206.                     break;
  207.                 case IDCANCEL:
  208.                     PostQuitMessage( 0 );
  209.                     break;
  210.                 case ID_BROWSE_LOGPATH:
  211.                     GetDlgItemText( hwnd, ID_LOGPATH, szCurrDir, MAX_PATH );
  212.                     p = ExpandPath( szCurrDir );
  213.                     if (p) {
  214.                         strcpy( szCurrDir, p );
  215.                         free( p );
  216.                     }
  217.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_LOGPATH ), FALSE );
  218.                     if (BrowseForDirectory( szCurrDir )) {
  219.                         SetDlgItemText( hwnd, ID_LOGPATH, szCurrDir );
  220.                     }
  221.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_LOGPATH ), TRUE );
  222.                     SetFocus( GetDlgItem(hwnd, ID_BROWSE_LOGPATH) );
  223.                     return FALSE;
  224.                     break;
  225.                 case ID_BROWSE_WAVEFILE:
  226.                     szWave[0] = '';
  227.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_WAVEFILE ), FALSE );
  228.                     if (GetWaveFileName( szWave )) {
  229.                         SetDlgItemText( hwnd, ID_WAVE_FILE, szWave );
  230.                     }
  231.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_WAVEFILE ), TRUE );
  232.                     SetFocus( GetDlgItem(hwnd, ID_BROWSE_WAVEFILE) );
  233.                     return FALSE;
  234.                     break;
  235.                 case ID_BROWSE_CRASH:
  236.                     szDump[0] = '';
  237.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_CRASH ), FALSE );
  238.                     if (GetDumpFileName( szDump )) {
  239.                         SetDlgItemText( hwnd, ID_CRASH_DUMP, szDump );
  240.                     }
  241.                     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_CRASH ), TRUE );
  242.                     SetFocus( GetDlgItem(hwnd, ID_BROWSE_CRASH) );
  243.                     return FALSE;
  244.                     break;
  245.                 case ID_CLEAR:
  246.                     ElClearAllEvents();
  247.                     InitializeCrashList( hwnd );
  248.                     break;
  249.                 case ID_TEST_WAVE:
  250.                     GetDlgItemText( hwnd, ID_WAVE_FILE, szWave, sizeof(szWave) );
  251.                     PlaySound( szWave, NULL, SND_FILENAME );
  252.                     break;
  253.                 case ID_LOGFILE_VIEW:
  254.                     DialogBoxParam( GetModuleHandle( NULL ),
  255.                            MAKEINTRESOURCE( LOGFILEVIEWERDIALOG ),
  256.                            hwnd,
  257.                            LogFileViewerDialogProc,
  258.                            SendMessage((HWND)GetDlgItem(hwnd,ID_CRASHES),
  259.                                         LB_GETCURSEL,0,0)
  260.                          );
  261.                     break;
  262.                 case ID_HELP:
  263.                     //
  264.                     // call winhelp
  265.                     //
  266.                     GetHelpFileName( szHelpFileName, sizeof(szHelpFileName ) );
  267.                     WinHelp( hwnd, szHelpFileName, HELP_FINDER, IDH_INDEX );
  268.                     SetFocus( GetDlgItem(hwnd, ID_HELP) );
  269.                     break;
  270.                 default:
  271.                     if (((HWND)lParam == GetDlgItem( hwnd, ID_CRASHES )) &&
  272.                         (HIWORD( wParam ) == LBN_DBLCLK)) {
  273.                         DialogBoxParam( GetModuleHandle( NULL ),
  274.                                MAKEINTRESOURCE( LOGFILEVIEWERDIALOG ),
  275.                                hwnd,
  276.                                LogFileViewerDialogProc,
  277.                                SendMessage((HWND)lParam,LB_GETCURSEL,0,0)
  278.                              );
  279.                     }
  280.                     if (((HWND)lParam == GetDlgItem( hwnd, ID_CRASH )) &&
  281.                         (HIWORD( wParam ) == BN_CLICKED)) {
  282.                         Checked = IsDlgButtonChecked( hwnd, ID_CRASH );
  283.                         EnableWindow( GetDlgItem( hwnd, ID_CRASH_DUMP_TEXT ), Checked == 1 );
  284.                         EnableWindow( GetDlgItem( hwnd, ID_CRASH_DUMP ), Checked == 1 );
  285.                         EnableWindow( GetDlgItem( hwnd, ID_BROWSE_CRASH ), Checked == 1 );
  286.                     }
  287.                     break;
  288.             }
  289.             break;
  290.         case WM_DESTROY:
  291.             PostQuitMessage( 0 );
  292.             return 0;
  293.     }
  294.     return DefWindowProc( hwnd, message, wParam, lParam );
  295. }
  296. BOOL CALLBACK
  297. EnumCrashes( PCRASHINFO crashInfo )
  298. /*++
  299. Routine Description:
  300.     Enumeration function for crash records.  This function is called
  301.     once for each crash record.  This function places the formatted
  302.     crash data in a listbox.
  303. Arguments:
  304.     crashInfo      - pointer to a CRASHINFO structure
  305. Return Value:
  306.     TRUE           - caller should continue calling the enum procedure
  307.     FALSE          - caller should stop calling the enum procedure
  308. --*/
  309. {
  310.     SIZE size;
  311.     char buf[1024];
  312.     wsprintf( buf, "%s  %08x  %s(%08x)",
  313.               crashInfo->crash.szAppName,
  314.               crashInfo->crash.dwExceptionCode,
  315.               crashInfo->crash.szFunction,
  316.               crashInfo->crash.dwAddress
  317.             );
  318.     SendMessage( crashInfo->hList, LB_ADDSTRING, 0, (LPARAM)buf );
  319.     GetTextExtentPoint( crashInfo->hdc, buf, strlen(buf), &size );
  320.     if (size.cx > (LONG)crashInfo->cxExtent) {
  321.         crashInfo->cxExtent = size.cx;
  322.     }
  323.     return TRUE;
  324. }
  325. void
  326. InitializeCrashList( HWND hwnd )
  327. /*++
  328. Routine Description:
  329.     Initializes the listbox that contains the crash information.
  330. Arguments:
  331.     None.
  332. Return Value:
  333.     None.
  334. --*/
  335. {
  336.     CRASHINFO     crashInfo;
  337.     TEXTMETRIC    tm;
  338.     HFONT         hFont;
  339.     crashInfo.hList = GetDlgItem( hwnd, ID_CRASHES );
  340.     SendMessage( crashInfo.hList, LB_RESETCONTENT, FALSE, 0L );
  341.     SendMessage( crashInfo.hList, WM_SETREDRAW, FALSE, 0L );
  342.     crashInfo.hdc = GetDC( crashInfo.hList );
  343.     crashInfo.cxExtent = 0;
  344.     ElEnumCrashes( &crashInfo, EnumCrashes );
  345.     hFont = (HFONT)SendMessage( crashInfo.hList, WM_GETFONT, 0, 0L );
  346.     if (hFont != NULL) {
  347.         SelectObject( crashInfo.hdc, hFont );
  348.     }
  349.     GetTextMetrics( crashInfo.hdc, &tm );
  350.     ReleaseDC( crashInfo.hList, crashInfo.hdc );
  351.     SendMessage( crashInfo.hList, LB_SETHORIZONTALEXTENT, crashInfo.cxExtent, 0L );
  352.     SendMessage( crashInfo.hList, WM_SETREDRAW, TRUE, 0L );
  353.     return;
  354. }
  355. void
  356. InitializeDialog( HWND hwnd )
  357. /*++
  358. Routine Description:
  359.     Initializes the DRWTSN32 user interface dialog with the values
  360.     stored in the registry.
  361. Arguments:
  362.     hwnd       - window handle to the dialog
  363. Return Value:
  364.     None.
  365. --*/
  366. {
  367.     OPTIONS       o;
  368.     char          buf[256];
  369.     HMENU         hMenu;
  370.     RegInitialize( &o );
  371.     SetDlgItemText( hwnd, ID_LOGPATH, o.szLogPath );
  372.     SetDlgItemText( hwnd, ID_WAVE_FILE, o.szWaveFile );
  373.     SetDlgItemText( hwnd, ID_CRASH_DUMP, o.szCrashDump );
  374.     wsprintf( buf, "%d", o.dwMaxCrashes );
  375.     SetDlgItemText( hwnd, ID_NUM_CRASHES, buf );
  376.     wsprintf( buf, "%d", o.dwInstructions );
  377.     SetDlgItemText( hwnd, ID_INSTRUCTIONS, buf );
  378.     SendMessage( GetDlgItem( hwnd, ID_DUMPSYMBOLS ), BM_SETCHECK, o.fDumpSymbols, 0 );
  379.     SendMessage( GetDlgItem( hwnd, ID_DUMPALLTHREADS ), BM_SETCHECK, o.fDumpAllThreads, 0 );
  380.     SendMessage( GetDlgItem( hwnd, ID_APPENDTOLOGFILE ), BM_SETCHECK, o.fAppendToLogFile, 0 );
  381.     SendMessage( GetDlgItem( hwnd, ID_VISUAL ), BM_SETCHECK, o.fVisual, 0 );
  382.     SendMessage( GetDlgItem( hwnd, ID_SOUND ), BM_SETCHECK, o.fSound, 0 );
  383.     SendMessage( GetDlgItem( hwnd, ID_CRASH ), BM_SETCHECK, o.fCrash, 0 );
  384.     if (waveOutGetNumDevs() == 0) {
  385.         EnableWindow( GetDlgItem( hwnd, ID_WAVEFILE_TEXT ), FALSE );
  386.         EnableWindow( GetDlgItem( hwnd, ID_WAVE_FILE ), FALSE );
  387.         EnableWindow( GetDlgItem( hwnd, ID_BROWSE_WAVEFILE ), FALSE );
  388.     }
  389.     EnableWindow( GetDlgItem( hwnd, ID_CRASH_DUMP_TEXT ), o.fCrash );
  390.     EnableWindow( GetDlgItem( hwnd, ID_CRASH_DUMP ), o.fCrash );
  391.     EnableWindow( GetDlgItem( hwnd, ID_BROWSE_CRASH ), o.fCrash );
  392.     InitializeCrashList( hwnd );
  393.     if (SendMessage( GetDlgItem( hwnd, ID_CRASHES ), LB_GETCOUNT, 0 ,0 ) == 0) {
  394.         EnableWindow( GetDlgItem( hwnd, ID_CLEAR ), FALSE );
  395.         EnableWindow( GetDlgItem( hwnd, ID_LOGFILE_VIEW ), FALSE );
  396.     }
  397.     hMenu = GetSystemMenu( hwnd, FALSE );
  398.     if (hMenu != NULL) {
  399.         AppendMenu( hMenu, MF_SEPARATOR, 0, NULL );
  400.         AppendMenu( hMenu, MF_STRING, ID_ABOUT, LoadRcString( IDS_ABOUT ) );
  401.     }
  402.     return;
  403. }
  404. BOOL
  405. GetDialogValues( HWND hwnd )
  406. /*++
  407. Routine Description:
  408.     Retrieves the values in the DRWTSN32 dialog controls and saves
  409.     them in the registry.
  410. Arguments:
  411.     hwnd       - window handle to the dialog
  412. Return Value:
  413.     TRUE       - all values were retrieved and saved
  414.     FALSE      - an error occurred
  415. --*/
  416. {
  417.     OPTIONS  o;
  418.     char     buf[256];
  419.     DWORD    dwFa;
  420.     LPSTR    p,p1;
  421.     char     szDrive    [_MAX_DRIVE];
  422.     char     szDir      [_MAX_DIR];
  423.     char     szPath     [MAX_PATH];
  424.     RegInitialize( &o );
  425.     GetDlgItemText( hwnd, ID_LOGPATH, buf, sizeof(buf) );
  426.     p = ExpandPath( buf );
  427.     if (p) {
  428.         dwFa = GetFileAttributes( p );
  429.         free( p );
  430.     } else {
  431.         dwFa = GetFileAttributes( buf );
  432.     }
  433.     if ((dwFa == 0xffffffff) || (!(dwFa&FILE_ATTRIBUTE_DIRECTORY))) {
  434.         NonFatalError( LoadRcString(IDS_INVALID_PATH) );
  435.         return FALSE;
  436.     }
  437.     if (strlen(buf) > 0) {
  438.         strcpy( o.szLogPath, buf );
  439.     }
  440.     o.fCrash = SendMessage( GetDlgItem( hwnd, ID_CRASH ), BM_GETCHECK, 0, 0 );
  441.     GetDlgItemText( hwnd, ID_CRASH_DUMP, buf, sizeof(buf) );
  442.     if (o.fCrash) {
  443.         p = ExpandPath( buf );
  444.         if (p) {
  445.             dwFa = GetFileAttributes( p );
  446.             free( p );
  447.         } else {
  448.             dwFa = GetFileAttributes( buf );
  449.         }
  450.         if (dwFa == 0xffffffff) {
  451.             //
  452.             // file does not exist, check to see if the dir is ok
  453.             //
  454.             p = ExpandPath( buf );
  455.             if (p) {
  456.                 p1 = p;
  457.             } else {
  458.                 p1 = buf;
  459.             }
  460.             _splitpath( p1, szDrive, szDir, NULL, NULL );
  461.             _makepath( szPath, szDrive, szDir, NULL, NULL );
  462.             if (p) {
  463.                 free( p );
  464.             }
  465.             dwFa = GetFileAttributes( szPath );
  466.             if (dwFa == 0xffffffff) {
  467.                 NonFatalError( LoadRcString(IDS_INVALID_CRASH_PATH) );
  468.                 return FALSE;
  469.             }
  470.         } else if (dwFa & FILE_ATTRIBUTE_DIRECTORY) {
  471.             NonFatalError( LoadRcString(IDS_INVALID_CRASH_PATH) );
  472.             return FALSE;
  473.         }
  474.         if (strlen(buf) > 0) {
  475.             strcpy( o.szCrashDump, buf );
  476.         }
  477.     }
  478.     GetDlgItemText( hwnd, ID_WAVE_FILE, buf, sizeof(buf) );
  479.     if (strlen(buf) > 0) {
  480.         dwFa = GetFileAttributes( buf );
  481.         if ((dwFa == 0xffffffff) || (dwFa&FILE_ATTRIBUTE_DIRECTORY)) {
  482.             NonFatalError( LoadRcString(IDS_INVALID_WAVE) );
  483.             return FALSE;
  484.         }
  485.     }
  486.     strcpy( o.szWaveFile, buf );
  487.     GetDlgItemText( hwnd, ID_NUM_CRASHES, buf, sizeof(buf) );
  488.     o.dwMaxCrashes = (DWORD) atol( buf );
  489.     GetDlgItemText( hwnd, ID_INSTRUCTIONS, buf, sizeof(buf) );
  490.     o.dwInstructions = (DWORD) atol( buf );
  491.     o.fDumpSymbols = SendMessage( GetDlgItem( hwnd, ID_DUMPSYMBOLS ), BM_GETCHECK, 0, 0 );
  492.     o.fDumpAllThreads = SendMessage( GetDlgItem( hwnd, ID_DUMPALLTHREADS ), BM_GETCHECK, 0, 0 );
  493.     o.fAppendToLogFile = SendMessage( GetDlgItem( hwnd, ID_APPENDTOLOGFILE ), BM_GETCHECK, 0, 0 );
  494.     o.fVisual = SendMessage( GetDlgItem( hwnd, ID_VISUAL ), BM_GETCHECK, 0, 0 );
  495.     o.fSound = SendMessage( GetDlgItem( hwnd, ID_SOUND ), BM_GETCHECK, 0, 0 );
  496.     RegSave( &o );
  497.     return TRUE;
  498. }
  499. BOOL CALLBACK
  500. EnumCrashesForViewer( PCRASHINFO crashInfo )
  501. /*++
  502. Routine Description:
  503.     Enumeration function for crash records.  This function is called
  504.     once for each crash record.  This function looks for s specific crash
  505.     that is identified by the crashIndex.
  506. Arguments:
  507.     crashInfo      - pointer to a CRASHINFO structure
  508. Return Value:
  509.     TRUE           - caller should continue calling the enum procedure
  510.     FALSE          - caller should stop calling the enum procedure
  511. --*/
  512. {
  513.     char *p;
  514.     if ((crashInfo->dwIndex == crashInfo->dwIndexDesired) &&
  515.         (crashInfo->dwCrashDataSize > 0) ) {
  516.         p = crashInfo->pCrashData;
  517.         crashInfo->pCrashData = malloc( crashInfo->dwCrashDataSize+10 );
  518.         memcpy( crashInfo->pCrashData, p, crashInfo->dwCrashDataSize+10 );
  519.         crashInfo->pCrashData[crashInfo->dwCrashDataSize] = 0;
  520.         return FALSE;
  521.     }
  522.     crashInfo->dwIndex++;
  523.     return TRUE;
  524. }
  525. BOOL CALLBACK
  526. LogFileViewerDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  527. /*++
  528. Routine Description:
  529.     Window procedure for the log file viewer dialog box.
  530. Arguments:
  531.     hwnd       - window handle to the dialog box
  532.     message    - message number
  533.     wParam     - first message parameter
  534.     lParam     - second message parameter
  535. Return Value:
  536.     TRUE       - did not process the message
  537.     FALSE      - did process the message
  538. --*/
  539. {
  540.     static CRASHINFO    crashInfo;
  541.     HFONT               hFont;
  542.     switch (message) {
  543.         case WM_INITDIALOG:
  544.             crashInfo.dwIndex = 0;
  545.             crashInfo.dwIndexDesired = lParam;
  546.             ElEnumCrashes( &crashInfo, EnumCrashesForViewer );
  547.             if (crashInfo.dwIndex != crashInfo.dwIndexDesired) {
  548.                 MessageBeep( 0 );
  549.                 EndDialog( hwnd, 0 );
  550.                 return FALSE;
  551.             }
  552.             SetDlgItemText( hwnd, ID_LOGFILE_VIEW, crashInfo.pCrashData );
  553.             hFont = GetStockObject( SYSTEM_FIXED_FONT );
  554.             Assert( hFont != NULL );
  555.             SendDlgItemMessage( hwnd,
  556.                                 ID_LOGFILE_VIEW,
  557.                                 WM_SETFONT,
  558.                                 (WPARAM) hFont,
  559.                                 (LPARAM) FALSE
  560.                               );
  561.             return TRUE;
  562.         case WM_COMMAND:
  563.             if (wParam == IDOK) {
  564.                 free( crashInfo.pCrashData );
  565.                 EndDialog( hwnd, 0 );
  566.             }
  567.             break;
  568.     }
  569.     return FALSE;
  570. }