home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / trace2.zip / TRACE2D.C < prev    next >
C/C++ Source or Header  |  1994-04-16  |  4KB  |  130 lines

  1. //-----------------------------------------------
  2. //-TRACERD.C Source code for TRACER file routines
  3. //-----------------------------------------------
  4.  
  5. #define INCL_PM
  6. #define INCL_WIN
  7. #define INCL_DOS
  8. #define INCL_WINLISTBOXES
  9. #define INCL_WINBUTTONS
  10. #define INCL_WINHOOKS
  11. #define INCL_ERRORS
  12.  
  13. #include <os2.h>
  14. #include <string.h>
  15. #include "trace2.h"
  16. #include "traceid.h"
  17.  
  18. //----------------------------------------------
  19. //-External references--------------------------
  20. //----------------------------------------------
  21. extern char    szLogFile[];
  22. extern BOOL    bUserRequestsScroll;
  23. extern BOOL    bUserRequestsLog;
  24. extern BOOL    bUserRequestsNewLog;
  25. extern HFILE   pLogFile;
  26. extern ULONG  ulAction;
  27. extern ULONG  ulBytesWritten;
  28.  
  29. //----------------------------------------------
  30. //--LogToFile()---------------------------------
  31. //----------------------------------------------
  32.  
  33. VOID LogToFile ( PSZ selector_string )
  34. {
  35. // write text string to log file
  36. DosWrite( pLogFile, (PSZ)selector_string,
  37.                          strlen(selector_string),
  38. /*                        (USHORT)80, */
  39.                         &ulBytesWritten );
  40. DosWrite( pLogFile, (PSZ)"\r\n",
  41.                          (USHORT)2, &ulBytesWritten );
  42. return;
  43. }
  44.  
  45. //----------------------------------------------
  46. //--TracerAboutDlg()----------------------------
  47. //----------------------------------------------
  48.  
  49. MRESULT EXPENTRY TracerAboutDlg( HWND hWndDlg, USHORT message,
  50.                                  MPARAM mp1, MPARAM mp2 )
  51. {
  52.     switch( message )
  53.     {
  54.       case WM_COMMAND:
  55.         /* the user has pressed a button */
  56.         switch( SHORT1FROMMP( mp1 ) )
  57.         {
  58.           case ID_OK:
  59.             WinDismissDlg( hWndDlg, TRUE );
  60.             break;
  61.  
  62.           default:
  63.             return( FALSE );
  64.         }
  65.         break;
  66.  
  67.       default:
  68.         return( WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
  69.     }
  70.     return( FALSE );
  71. }
  72.  
  73. //----------------------------------------------
  74. //--TracerLogFileDlg()--------------------------
  75. //----------------------------------------------
  76.  
  77. MRESULT EXPENTRY TracerLogFileDlg( HWND hWndDlg, USHORT message,
  78.                                  MPARAM mp1, MPARAM mp2 )
  79. {
  80.     switch( message )
  81.     {
  82.       case WM_INITDLG:
  83.  
  84.         // options controls init
  85.         WinSendDlgItemMsg( hWndDlg, ID_LOGFILESCROLL, BM_SETCHECK,
  86.             MPFROM2SHORT( (bUserRequestsLog) ? 1 : 0, 0), 0L );
  87.         WinSendDlgItemMsg( hWndDlg, ID_SCREENSCROLL, BM_SETCHECK,
  88.             MPFROM2SHORT( (bUserRequestsScroll) ? 1 : 0, 0), 0L );
  89.  
  90.       case WM_COMMAND:
  91.         switch( SHORT1FROMMP( mp1 ) )
  92.         {
  93.           case ID_CANCEL:
  94.             WinDismissDlg( hWndDlg, TRUE );
  95.             break;
  96.  
  97.           case ID_OK:
  98.  
  99.             // if user wishes to truncate log file, do it
  100.             if (
  101.             bUserRequestsNewLog =
  102.                  (BOOL) WinSendDlgItemMsg( hWndDlg,
  103.                      ID_SCREENSCROLL, BM_QUERYCHECK, 0L, 0L ) )
  104.                  DosSetFileSize( pLogFile, 0L );
  105.  
  106.             // does user wish to see messages on screen ?
  107.             bUserRequestsScroll =
  108.                 (BOOL) WinSendDlgItemMsg( hWndDlg,
  109.                      ID_SCREENSCROLL, BM_QUERYCHECK, 0L, 0L );
  110.  
  111.             // does user wish to log messages to file ?
  112.             bUserRequestsLog =
  113.                 (BOOL) WinSendDlgItemMsg( hWndDlg,
  114.                      ID_LOGFILESCROLL, BM_QUERYCHECK, 0L, 0L );
  115.  
  116.             WinDismissDlg( hWndDlg, TRUE );
  117.  
  118.             break;
  119.  
  120.           default:
  121.             return( FALSE );
  122.         }
  123.         break;
  124.  
  125.       default:
  126.         return( WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
  127.     }
  128.     return( FALSE );
  129. }
  130.