home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / graphic / dkb / source / tracepm.c < prev    next >
C/C++ Source or Header  |  1992-08-04  |  16KB  |  530 lines

  1. /*
  2.  
  3. DKB Raytracer for OS/2 2.0 Presentation Manager
  4. by Michael Caldwell (mcaldwel@netcom.com)
  5.  
  6. */
  7.  
  8. #define INCL_PM
  9. #define INCL_WINMLE
  10. #define INCL_WINSTDFILE
  11. #define INCL_DOSPROCESS
  12. #include <os2.h>
  13. #include <stdarg.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include "tracepm.h"
  18. #include "trace.h"
  19.  
  20.  
  21. /* memory is allocated in 4K pages in OS/2 2.0 */
  22. #define BUFFER_SIZE 4096
  23. #define TRACE_STACK_SIZE 8192
  24. #define QUEUE_SIZE 256
  25. #define WM_INIT_OPTIONS WM_USER
  26. #define WM_PRINT WM_USER + 1
  27. #define WM_STATS WM_USER + 2
  28. #define WM_PLOT WM_USER + 3
  29. #define WM_MENUS WM_USER + 4
  30. /* these defines are copied from frame.h */
  31. #define DISPLAY 1
  32. #define VERBOSE 2
  33. #define DISKWRITE 4
  34. #define ANTIALIAS 16
  35. /* ------------------------------------- */
  36.  
  37.  
  38. extern unsigned int Options;
  39. extern char Output_File_Name [];
  40. extern char OutputFormat;
  41. extern int Screen_Width;
  42. extern int Screen_Height;
  43. extern double Antialias_Threshold;
  44. extern int Quality;
  45. extern int Stop_Flag;
  46.  
  47.  
  48. FILEDLG    fd;
  49. HAB        hab;
  50. HMQ        hmq;
  51. HWND        hwndMain = (HWND) NULL;
  52. HWND        hwndTranscript = (HWND) NULL;
  53. HWND        hwndMenu = (HWND) NULL;
  54. IPT        ipt = 0;
  55. PSZ        pszPrintToTranscriptError = "Error: cannot print to transcript.\n";
  56. PSZ        pszAppName = "Trace PM";
  57. PSZ        pszImage = "Image";
  58.  
  59.  
  60. static HWND hwndFrame = (HWND) NULL;
  61.  
  62.  
  63. MRESULT EXPENTRY MainWndProc (HWND, ULONG, MPARAM, MPARAM);
  64. MRESULT EXPENTRY TraceWndProc (HWND, ULONG, MPARAM, MPARAM);
  65. MRESULT EXPENTRY ImageWndProc (HWND, ULONG, MPARAM, MPARAM);
  66. VOID _System StartTracePM (PSZ pszInputFileName);
  67. VOID SetPixel (SHORT x, SHORT y, LONG lColor);
  68. VOID UpdateStats (SHORT y);
  69. void text_main (int argc, char * * argv);
  70. void StartTrace (char * Input_File_Name);
  71. void print_line_stats (register int y);
  72. void display_init (int x, int y);
  73.  
  74.  
  75. int main (int argc, char * * argv) {
  76.     QMSG        qmsg;
  77.     ULONG        fl;
  78.  
  79.     hab = WinInitialize (0);
  80.     if (! hab)
  81.         DosExit (EXIT_PROCESS, 1);
  82.  
  83.     hmq = WinCreateMsgQueue (hab, QUEUE_SIZE);
  84.     if (! hmq) {
  85.         WinTerminate (hab);
  86.         DosExit (EXIT_PROCESS, 1);
  87.     }
  88.     if (! WinRegisterClass (hab, pszAppName, MainWndProc, 0L, 0)) {
  89.         WinDestroyMsgQueue (hmq);
  90.         WinTerminate (hab);
  91.         DosExit (EXIT_PROCESS, 1);
  92.     }
  93.     if (! WinRegisterClass (hab, pszImage, ImageWndProc, CS_SIZEREDRAW, 0)) {
  94.         WinDestroyMsgQueue (hmq);
  95.         WinTerminate (hab);
  96.         DosExit (EXIT_PROCESS, 1);
  97.     }
  98.     fl = FCF_STANDARD & ~ FCF_ACCELTABLE;
  99.     hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE, & fl, pszAppName,
  100.             pszAppName, WS_VISIBLE, (HMODULE) NULL, ID_MAIN, & hwndMain);
  101.     if (! hwndFrame) {
  102.         WinDestroyMsgQueue (hmq);
  103.         WinTerminate (hab);
  104.         DosExit (EXIT_PROCESS, 1);
  105.     }
  106.     WinPostMsg (hwndMain, WM_INIT_OPTIONS, (MPARAM) argc, (MPARAM) argv);
  107.     while (WinGetMsg (hmq, & qmsg, 0, 0, 0))
  108.         WinDispatchMsg (hmq, & qmsg);
  109.  
  110.     WinDestroyMsgQueue (hmq);
  111.     WinTerminate (hab);
  112.     DosExit (EXIT_PROCESS, 0);
  113.     return (0);
  114. }/* end main */
  115.  
  116.  
  117. VOID PrintToTranscript (PSZ pszFormat, ...) {
  118.     PSZ        pszString;
  119.     SHORT        sLength;
  120.     va_list    valist;
  121.  
  122.     if (DosAllocMem ((PPVOID) & pszString, BUFFER_SIZE, fALLOC)) {
  123.     /* zeros indicate an error */
  124.         WinPostMsg (hwndMain, WM_PRINT, 0L, 0L);
  125.         return;
  126.     }
  127.     va_start (valist, pszFormat);
  128.     sLength = vsprintf (pszString, pszFormat, valist);
  129.     va_end (valist);
  130.     WinPostMsg (hwndMain, WM_PRINT, (MPARAM) pszString, (MPARAM) sLength);
  131. }/* end PrintToTranscript */
  132.  
  133.  
  134. VOID AddStringToTranscript (PSZ pszString, SHORT sLength) {
  135.     if (! pszString) {
  136.         sLength = strlen (pszPrintToTranscriptError);
  137.         WinSendMsg (hwndTranscript, MLM_SETIMPORTEXPORT,
  138.                 (MPARAM) pszPrintToTranscriptError, (MPARAM) sLength);
  139.         WinSendMsg (hwndTranscript, MLM_IMPORT, (MPARAM) & ipt,
  140.                 (MPARAM) sLength);
  141.         return;
  142.     }
  143.     WinSendMsg (hwndTranscript, MLM_SETIMPORTEXPORT, (MPARAM) pszString,
  144.             (MPARAM) sLength);
  145.     WinSendMsg (hwndTranscript, MLM_IMPORT, (MPARAM) & ipt, (MPARAM) sLength);
  146.     DosFreeMem (pszString);
  147. }/* end AddStringToTranscript */
  148.  
  149.  
  150. VOID DisableMenus (SHORT sDisable) {
  151.     if (sDisable) sDisable = MIA_DISABLED;
  152.     WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_TRACE, TRUE),
  153.             MPFROM2SHORT (MIA_DISABLED, sDisable));
  154.     WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_ABORT, TRUE),
  155.             MPFROM2SHORT (MIA_DISABLED, sDisable == FALSE ? MIA_DISABLED : TRUE));
  156.     WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_DISPLAY, TRUE),
  157.             MPFROM2SHORT (MIA_DISABLED, sDisable));
  158.     WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_OUTPUT, TRUE),
  159.             MPFROM2SHORT (MIA_DISABLED, sDisable));
  160.     WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_QUALITY, TRUE),
  161.             MPFROM2SHORT (MIA_DISABLED, sDisable));
  162. }/* end DisableMenus */
  163.  
  164.  
  165. VOID TracePM () {
  166.     TID            tid;
  167.  
  168.     memset (& fd, 0, sizeof (FILEDLG));
  169.     fd.cbSize = sizeof (FILEDLG);
  170.     fd.fl = FDS_CENTER | FDS_OPEN_DIALOG;
  171.     fd.pszTitle = pszAppName;
  172.     strcpy (fd.szFullFile, "*.dat");
  173.     if (WinFileDlg (HWND_DESKTOP, hwndMain, & fd) && fd.lReturn == DID_OK) {
  174.        if (Options & DISKWRITE) {
  175.             PSZ    pszS;
  176.             PSZ    pszE;
  177.  
  178.             pszS = strrchr (fd.szFullFile, '\\') + 1;
  179.             pszE = strchr (pszS, '.');
  180.             if (pszE) {
  181.                 strncpy (Output_File_Name, pszS, pszE - pszS);
  182.                 Output_File_Name [pszE - pszS] = 0;
  183.             } else {
  184.                 strcpy (Output_File_Name, pszS);
  185.             }
  186.           switch (OutputFormat) {
  187.              case 'd':
  188.                     strcat (Output_File_Name, ".dis");
  189.                 break;
  190.  
  191.              case 't':
  192.                     strcat (Output_File_Name, ".tga");
  193.                 break;
  194.             }
  195.         } else {
  196.             Output_File_Name [0] = 0;
  197.         }
  198.         if (WinDlgBox (HWND_DESKTOP, hwndMain, TraceWndProc, (HMODULE) NULL,
  199.                 ID_TRACEDIALOG, fd.szFullFile)) {
  200.             DisableMenus (TRUE);
  201.  
  202.         /* open display windows from thread 1 */
  203.             if (Options & VERBOSE)
  204.                 print_line_stats (-2);
  205.               if (Options & DISPLAY)
  206.                 display_init (Screen_Width, Screen_Height);
  207.  
  208.             if (DosCreateThread (& tid, (PFNTHREAD) StartTracePM,
  209.                     (ULONG) fd.szFullFile, 0, TRACE_STACK_SIZE)) {
  210.                 PrintToTranscript ("Error: unable to start trace thread.\n");
  211.             }
  212.         }
  213.     }
  214. }/* end TracePM */
  215.  
  216.  
  217. VOID PostMessage (HWND hwnd, ULONG ulMessage, MPARAM mp1, MPARAM mp2) {
  218. /* this function is for thread 2 (the trace thread) */
  219.     while (! WinPostMsg (hwnd, ulMessage, mp1, mp2)) {
  220.     /* give up the rest of this time slice and try the post message again */
  221.         DosSleep (0L);
  222.     }/*endWhile*/
  223. }/* end PostMessage */
  224.  
  225.  
  226. VOID _System StartTracePM (PSZ pszInputFileName) {
  227.     Stop_Flag = FALSE;
  228.     StartTrace (pszInputFileName);
  229.     PostMessage (hwndMain, WM_MENUS, 0L, 0L);
  230. }/* end StartTracePM */
  231.  
  232.  
  233. void print_line_stats (register int y) {
  234.     PostMessage (hwndMain, WM_STATS, (MPARAM) y, 0L);
  235. }/* end print_line_stats */
  236.  
  237.  
  238. #define RGB(r,g,b) ((LONG)(BYTE)(r)<<16|(LONG)(BYTE)(g)<<8|(BYTE)(b))
  239.  
  240.  
  241. void display_plot (int x, int y, char Red, char Green, char Blue) {
  242.     PostMessage (hwndMain, WM_PLOT, MPFROM2SHORT ((SHORT) x, (SHORT) y),
  243.             (MPARAM) RGB (Red, Green, Blue));
  244. }/* end display_plot */
  245.  
  246.  
  247. MRESULT EXPENTRY MainWndProc (HWND hwnd, ULONG ulMessage, MPARAM mp1,
  248.         MPARAM mp2) {
  249.     switch (ulMessage) {
  250.         case WM_COMMAND: {
  251.             if (SHORT1FROMMP (mp2) == CMDSRC_MENU) {
  252.                 switch (SHORT1FROMMP (mp1)) {
  253.                     case ID_TRACE: {
  254.                         TracePM ();
  255.                         break;
  256.                     }
  257.                     case ID_ABORT: {
  258.                         Stop_Flag = TRUE;
  259.                         break;
  260.                     }
  261.                     case ID_EXIT: {
  262.                         WinPostMsg (hwndMain, WM_QUIT, 0L, 0L);
  263.                         break;
  264.                     }
  265.                     case ID_IMAGE: {
  266.                         if (Options & DISPLAY) {
  267.                             Options &= ~ DISPLAY;
  268.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  269.                                     MPFROM2SHORT (ID_IMAGE, TRUE),
  270.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  271.                         } else {
  272.                             Options |= DISPLAY;
  273.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  274.                                     MPFROM2SHORT (ID_IMAGE, TRUE),
  275.                                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  276.                         }
  277.                         break;
  278.                     }
  279.                     case ID_STATISTICS: {
  280.                         if (Options & VERBOSE) {
  281.                             Options &= ~ VERBOSE;
  282.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  283.                                     MPFROM2SHORT (ID_STATISTICS, TRUE),
  284.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  285.                         } else {
  286.                             Options |= VERBOSE;
  287.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  288.                                     MPFROM2SHORT (ID_STATISTICS, TRUE),
  289.                                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  290.                         }
  291.                         break;
  292.                     }
  293.                     case ID_TARGA: {
  294.                         if (Options & DISKWRITE && OutputFormat == 't') {
  295.                             Options &= ~ DISKWRITE;
  296.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  297.                                     MPFROM2SHORT (ID_TARGA, TRUE),
  298.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  299.                         } else {
  300.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  301.                                     MPFROM2SHORT (ID_DUMP, TRUE),
  302.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  303.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  304.                                     MPFROM2SHORT (ID_RAW, TRUE),
  305.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  306.                             Options |= DISKWRITE;
  307.                             OutputFormat = 't';
  308.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  309.                                     MPFROM2SHORT (ID_TARGA, TRUE),
  310.                                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  311.                         }
  312.                         break;
  313.                     }
  314.                     case ID_DUMP: {
  315.                         if (Options & DISKWRITE && OutputFormat == 'd') {
  316.                             Options &= ~ DISKWRITE;
  317.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  318.                                     MPFROM2SHORT (ID_DUMP, TRUE),
  319.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  320.                         } else {
  321.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  322.                                     MPFROM2SHORT (ID_TARGA, TRUE),
  323.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  324.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  325.                                     MPFROM2SHORT (ID_RAW, TRUE),
  326.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  327.                             Options |= DISKWRITE;
  328.                             OutputFormat = 'd';
  329.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  330.                                     MPFROM2SHORT (ID_DUMP, TRUE),
  331.                                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  332.                         }
  333.                         break;
  334.                     }
  335.                     case ID_RAW: {
  336.                         if (Options & DISKWRITE && OutputFormat == 'r') {
  337.                             Options &= ~ DISKWRITE;
  338.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  339.                                     MPFROM2SHORT (ID_RAW, TRUE),
  340.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  341.                         } else {
  342.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  343.                                     MPFROM2SHORT (ID_TARGA, TRUE),
  344.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  345.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  346.                                     MPFROM2SHORT (ID_DUMP, TRUE),
  347.                                     MPFROM2SHORT (MIA_CHECKED, FALSE));
  348.                             Options |= DISKWRITE;
  349.                             OutputFormat = 'r';
  350.                             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  351.                                     MPFROM2SHORT (ID_RAW, TRUE),
  352.                                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  353.                         }
  354.                         break;
  355.                     }
  356.                     case ID_0:
  357.                     case ID_1:
  358.                     case ID_2:
  359.                     case ID_3:
  360.                     case ID_4:
  361.                     case ID_5:
  362.                     case ID_6:
  363.                     case ID_7:
  364.                     case ID_8:
  365.                     case ID_9: {
  366.                         WinSendMsg (hwndMenu, MM_SETITEMATTR,
  367.                                 MPFROM2SHORT (ID_0 + Quality, TRUE),
  368.                                 MPFROM2SHORT (MIA_CHECKED, FALSE));
  369.                         Quality = SHORT1FROMMP (mp1) - ID_0;
  370.                         WinSendMsg (hwndMenu, MM_SETITEMATTR,
  371.                                 MPFROM2SHORT (ID_0 + Quality, TRUE),
  372.                                 MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  373.                         break;
  374.                     }
  375.                 }
  376.                 return (0L);
  377.             }
  378.             break;
  379.         }
  380.         case WM_SIZE: {
  381.             if (! hwndTranscript) {
  382.                 hwndTranscript = WinCreateWindow (hwnd, WC_MLE, "", WS_VISIBLE
  383.                         | MLS_VSCROLL | MLS_HSCROLL | MLS_READONLY, 0, 0,
  384.                         SHORT1FROMMP (mp2), SHORT2FROMMP (mp2), hwnd, HWND_TOP, 0,
  385.                         NULL, NULL);
  386.                 if (hwndTranscript) {
  387.                     WinSendMsg (hwndTranscript, MLM_FORMAT, (MPARAM) MLFIE_NOTRANS,
  388.                             0L);
  389.                 }
  390.             } else {
  391.                 WinSetWindowPos (hwndTranscript, HWND_TOP, 0, 0,
  392.                         SHORT1FROMMP (mp2), SHORT2FROMMP (mp2), SWP_MOVE | SWP_SIZE);
  393.             }
  394.             return (0L);
  395.         }
  396.         case WM_INIT_OPTIONS: {
  397.             text_main ((int) mp1, (char * *) mp2);
  398.             hwndMenu = WinWindowFromID (hwndFrame, FID_MENU);
  399.             WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (ID_ABORT, TRUE),
  400.                     MPFROM2SHORT (MIA_DISABLED, MIA_DISABLED));
  401.             if (Options & DISKWRITE) {
  402.                 SHORT        sID;
  403.  
  404.                 switch (OutputFormat) {
  405.                     case 'd': {
  406.                         sID = ID_DUMP;
  407.                         break;
  408.                     }
  409.                     case 't': {
  410.                         sID = ID_TARGA;
  411.                         break;
  412.                     }
  413.                     case 'r': {
  414.                         sID = ID_RAW;
  415.                         break;
  416.                     }
  417.                 }
  418.                 WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (sID, TRUE),
  419.                         MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  420.             }
  421.             if (Options & DISPLAY) {
  422.                 WinSendMsg (hwndMenu, MM_SETITEMATTR,
  423.                         MPFROM2SHORT (ID_IMAGE, TRUE),
  424.                         MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  425.             }
  426.             if (Options & VERBOSE) {
  427.                 WinSendMsg (hwndMenu, MM_SETITEMATTR,
  428.                         MPFROM2SHORT (ID_STATISTICS, TRUE),
  429.                         MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  430.             }
  431.             WinSendMsg (hwndMenu, MM_SETITEMATTR,
  432.                     MPFROM2SHORT (ID_0 + Quality, TRUE),
  433.                     MPFROM2SHORT (MIA_CHECKED, MIA_CHECKED));
  434.             return (0L);
  435.         }
  436.         case WM_PRINT: {
  437.             AddStringToTranscript ((PSZ) mp1, (SHORT) mp2);
  438.             return (0L);
  439.         }
  440.         case WM_STATS: {
  441.             UpdateStats ((SHORT) mp1);
  442.             return (0L);
  443.         }
  444.         case WM_PLOT: {
  445.             SetPixel (SHORT1FROMMP (mp1), SHORT2FROMMP (mp1), (LONG) mp2);
  446.             return (0L);
  447.         }
  448.         case WM_MENUS: {
  449.             DisableMenus (FALSE);
  450.             return (0L);
  451.         }
  452.     }/*endSwitch*/
  453.     return (WinDefWindowProc (hwnd, ulMessage, mp1, mp2));
  454. }/* end MainWndProc */
  455.  
  456.  
  457. MRESULT EXPENTRY TraceWndProc (HWND hwnd, ULONG ulMessage, MPARAM mp1,
  458.         MPARAM mp2) {
  459.     switch (ulMessage) {
  460.         case WM_INITDLG: {
  461.             PSZ        pszThreshold [32];
  462.  
  463.             WinSendMsg (WinWindowFromID (hwnd, ID_IFILENAME), EM_SETTEXTLIMIT,
  464.                     (MPARAM) CCHMAXPATH, 0L);
  465.             WinSetDlgItemText (hwnd, ID_IFILENAME, mp2);
  466.             if (Options & DISKWRITE) {
  467.                 WinSendMsg (WinWindowFromID (hwnd, ID_OFILENAME), EM_SETTEXTLIMIT,
  468.                         (MPARAM) CCHMAXPATH, 0L);
  469.                 WinSetDlgItemText (hwnd, ID_OFILENAME, Output_File_Name);
  470.                 WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, ID_OFILENAME));
  471.             } else {
  472.                 WinEnableWindow (WinWindowFromID (hwnd, ID_OFILENAME), FALSE);
  473.                 WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, ID_WIDTH));
  474.             }
  475.             WinSetDlgItemShort (hwnd, ID_WIDTH, Screen_Width, FALSE);
  476.             WinSetDlgItemShort (hwnd, ID_HEIGHT, Screen_Height, FALSE);
  477.             if (Options & ANTIALIAS) {
  478.                 WinSendMsg (WinWindowFromID (hwnd, ID_ANTIALIAS), BM_SETCHECK,
  479.                         (MPARAM) 1L, 0L);
  480.             }
  481.         /* why isn't there a WinSetDlgItemDouble */
  482.             sprintf ((PSZ) pszThreshold, "%lf", Antialias_Threshold);
  483.             WinSetDlgItemText (hwnd, ID_THRESHOLD, (PSZ) pszThreshold);
  484.             return ((MPARAM) 1L);
  485.         }
  486.         case WM_COMMAND: {
  487.             if (SHORT1FROMMP (mp2) == CMDSRC_PUSHBUTTON) {
  488.                 switch (SHORT1FROMMP (mp1)) {
  489.                     case ID_OK: {
  490.                         PSZ        pszThreshold [32];
  491.                         SHORT        sValue;
  492.  
  493.                         if (Options & DISKWRITE) {
  494.                             WinQueryDlgItemText (hwnd, ID_OFILENAME, CCHMAXPATH,
  495.                                     Output_File_Name);
  496.                         }
  497.                     /* why isn't there a WinQueryDlgItemInt */
  498.                         WinQueryDlgItemShort (hwnd, ID_WIDTH, & sValue, FALSE);
  499.                         Screen_Width = sValue;
  500.                         WinQueryDlgItemShort (hwnd, ID_HEIGHT, & sValue, FALSE);
  501.                         Screen_Height = sValue;
  502.                         if (WinSendMsg (WinWindowFromID (hwnd, ID_ANTIALIAS),
  503.                                 BM_QUERYCHECK, 0L, 0L)) {
  504.                             Options |= ANTIALIAS;
  505.                         } else {
  506.                             Options &= ~ ANTIALIAS;
  507.                         }
  508.                         WinQueryDlgItemText (hwnd, ID_THRESHOLD, 32,
  509.                                 (PSZ) pszThreshold);
  510.                         Antialias_Threshold = atof ((PSZ) pszThreshold);
  511.                         WinDismissDlg (hwnd, 1);
  512.                         break;
  513.                     }
  514.                     case ID_CANCEL: {
  515.                         WinDismissDlg (hwnd, 0);
  516.                         break;
  517.                     }
  518.                   }
  519.                 return (0L);
  520.               }
  521.             break;
  522.         }
  523.         case WM_CLOSE: {
  524.             WinDismissDlg (hwnd, 0);
  525.             return (0L);
  526.         }
  527.     }/*endSwitch*/
  528.     return (WinDefDlgProc (hwnd, ulMessage, mp1, mp2));
  529. }/* end TraceWndProc */
  530.