home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12546.ZIP / TRACERD.C < prev    next >
Text File  |  1990-03-19  |  4KB  |  126 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 "tracer.h"
  15.  
  16. //----------------------------------------------
  17. //-External references--------------------------
  18. //----------------------------------------------
  19. extern char    szLogFile[];
  20. extern BOOL    bUserRequestsScroll;
  21. extern BOOL    bUserRequestsLog;
  22. extern BOOL    bUserRequestsNewLog;
  23. extern HFILE   pLogFile;
  24. extern USHORT  pusAction;
  25. extern USHORT  pusBytesWritten;
  26.  
  27. //----------------------------------------------
  28. //--LogToFile()---------------------------------
  29. //----------------------------------------------
  30.  
  31. VOID LogToFile ( PSZ selector_string )
  32. {
  33. // write text string to log file
  34. DosWrite( pLogFile, (char far *)selector_string,
  35.                          (USHORT)80, &pusBytesWritten );
  36. DosWrite( pLogFile, (char far *)"\r\n",
  37.                          (USHORT)2, &pusBytesWritten );
  38. return;
  39. }
  40.  
  41. //----------------------------------------------
  42. //--TracerAboutDlg()----------------------------
  43. //----------------------------------------------
  44.  
  45. MRESULT EXPENTRY TracerAboutDlg( HWND hWndDlg, USHORT message,
  46.                                  MPARAM mp1, MPARAM mp2 )
  47. {
  48.     switch( message )
  49.     {
  50.       case WM_COMMAND:
  51.         /* the user has pressed a button */
  52.         switch( SHORT1FROMMP( mp1 ) )
  53.         {
  54.           case ID_OK:
  55.             WinDismissDlg( hWndDlg, TRUE );
  56.             break;
  57.  
  58.           default:
  59.             return( FALSE );
  60.         }
  61.         break;
  62.  
  63.       default:
  64.         return( WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
  65.     }
  66.     return( FALSE );
  67. }
  68.  
  69. //----------------------------------------------
  70. //--TracerLogFileDlg()--------------------------
  71. //----------------------------------------------
  72.  
  73. MRESULT EXPENTRY TracerLogFileDlg( HWND hWndDlg, USHORT message,
  74.                                  MPARAM mp1, MPARAM mp2 )
  75. {
  76.     switch( message )
  77.     {
  78.       case WM_INITDLG:
  79.  
  80.         // options controls init
  81.         WinSendDlgItemMsg( hWndDlg, ID_LOGFILESCROLL, BM_SETCHECK,
  82.             MPFROM2SHORT( (bUserRequestsLog) ? 1 : 0, 0), 0L );
  83.         WinSendDlgItemMsg( hWndDlg, ID_SCREENSCROLL, BM_SETCHECK,
  84.             MPFROM2SHORT( (bUserRequestsScroll) ? 1 : 0, 0), 0L );
  85.  
  86.       case WM_COMMAND:
  87.         switch( SHORT1FROMMP( mp1 ) )
  88.         {
  89.           case ID_CANCEL:
  90.             WinDismissDlg( hWndDlg, TRUE );
  91.             break;
  92.  
  93.           case ID_OK:
  94.  
  95.             // if user wishes to truncate log file, do it
  96.             if (
  97.             bUserRequestsNewLog =
  98.              (SHORT)WinSendDlgItemMsg( hWndDlg,
  99.                      ID_SCREENSCROLL, BM_QUERYCHECK, 0L, 0L ) )
  100.                  DosNewSize( pLogFile, 0L );
  101.  
  102.             // does user wish to see messages on screen ?
  103.             bUserRequestsScroll =
  104.              (SHORT)WinSendDlgItemMsg( hWndDlg,
  105.                      ID_SCREENSCROLL, BM_QUERYCHECK, 0L, 0L );
  106.  
  107.             // does user wish to log messages to file ?
  108.             bUserRequestsLog =
  109.              (SHORT)WinSendDlgItemMsg( hWndDlg,
  110.                      ID_LOGFILESCROLL, BM_QUERYCHECK, 0L, 0L );
  111.  
  112.             WinDismissDlg( hWndDlg, TRUE );
  113.  
  114.             break;
  115.  
  116.           default:
  117.             return( FALSE );
  118.         }
  119.         break;
  120.  
  121.       default:
  122.         return( WinDefDlgProc( hWndDlg, message, mp1, mp2 ) );
  123.     }
  124.     return( FALSE );
  125. }
  126.