home *** CD-ROM | disk | FTP | other *** search
/ Inside Multimedia 1995 July / IMM0795.ISO / share / os2 / ssaver14 / sample.lzh / sample.c < prev    next >
C/C++ Source or Header  |  1994-07-17  |  18KB  |  540 lines

  1. /*
  2.     sample.c
  3.     sample saver module C source file version 1.4
  4.     (C) 1993-94 Siegfried Hanisch
  5. */
  6.  
  7. #define INCL_DOS
  8. #define INCL_DOSERRORS
  9. #define INCL_WIN
  10. #define INCL_GPI
  11. #include <os2.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <limits.h>
  16. #include <process.h>
  17.  
  18. #include "sample.h"
  19.  
  20.  
  21. // ===== preprocessor definitions
  22.  
  23. #define MODULEVERSION        0x00010004
  24. #define STACKSIZE        32000
  25. #define SAVER_NAME_MAXLEN    32
  26. #define FUNCTION_CONFIGURE    1
  27. #define FUNCTION_STARTSAVER    2
  28. #define FUNCTION_STOPSAVER    3
  29. #define FUNCTION_QUERYNAME    4
  30. #define FUNCTION_QUERYENABLED    5
  31. #define FUNCTION_SETENABLED    6
  32. #define CONFIGURATION_DEFAULT_ANIMATIONSPEED 4    // 0=slow .. 4=fast
  33. /*
  34.     $$$$$ insert code here $$$$$
  35.     This is the place for your preprocessor definitions.
  36.  
  37.     $$$$$ for example $$$$$
  38. #define CONFIGURATION_MINIMUM_COUNT 1
  39. #define CONFIGURATION_DEFAULT_COUNT 32
  40. #define CONFIGURATION_MAXIMUM_COUNT 100
  41. */
  42.  
  43. // ===== prototypes
  44.  
  45. void    EXPENTRY SAVER_PROC(int function, HAB _hab, HWND hwndOwner, char *appname, void *buffer);
  46. static    MRESULT EXPENTRY SaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  47. static    MRESULT EXPENTRY ConfigureDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  48. #if defined(__IBMC__)
  49. static    void    _Optlink draw_thread(void *args);
  50. static    void    _Optlink priority_thread(void *args);
  51. #elif defined(__BORLANDC__)
  52. static    void    _USERENTRY draw_thread(void *args);
  53. static    void    _USERENTRY priority_thread(void *args);
  54. #else
  55. static    void    draw_thread(void *args);
  56. static    void    priority_thread(void *args);
  57. #endif
  58. static    void    load_configuration_data(void);
  59.  
  60.  
  61. // ===== global data
  62.  
  63. ULONG    MODULESOURCE_VERSION = 0x00010004;    // EXPORTED: ScreenSaver 1.4 module source code (do not change)
  64.  
  65. static    LONG    screenSizeX = 0;        // screen size x
  66. static    LONG    screenSizeY = 0;        // screen size y
  67. static    HWND    hwndSaver = NULLHANDLE;     // saver window handle
  68. static    HMODULE hmodDLL = NULLHANDLE;        // saver module dll handle
  69. static    char    *application_name;        // name of ScreenSaver app
  70. static    TID    tidDraw;            // drawing-thread ID
  71. static    TID    tidPriority;            // priority regulation thread ID
  72. static    HPS    hps;                // presentation space handle
  73. static    HAB    hab;                // anchor block handle
  74. static    BOOL    low_priority = TRUE;        // low-priority flag
  75. static    BOOL    configuration_data_loaded = FALSE; // config data loaded flag
  76. static    volatile BOOL stop_draw_thread;     // stop flag
  77. static    char    modulename[SAVER_NAME_MAXLEN+1]; // module name buffer
  78. static    volatile BOOL stop_priority_thread = FALSE;
  79.  
  80. static    struct    _configuration_data {
  81.     ULONG    version;
  82.     BOOL    enabled;
  83.     int    animation_speed;
  84. /*
  85.     $$$$$ insert code here $$$$$
  86.     If your saver module needs some additional configuration data,
  87.     insert it here. It is automatically loaded and saved.
  88.  
  89.     $$$$$ for example $$$$$
  90.     int    count;
  91. */
  92. } configuration_data;
  93.  
  94.  
  95. // ===== code
  96.  
  97. /*
  98.     SAVER_PROC
  99.     This is the entry point into the saver module that is called by
  100.     the ScreenSaver program.
  101.     There should be no reason to alter the code.
  102.     Depending on the requested function, the following tasks
  103.     are performed:
  104.     * call the configuration dialog of the saver module
  105.     * copy the name of the saver module into the supplied buffer
  106.     * tell if the saver module is enabled
  107.     * set the "enabled" state of the saver module
  108.     * start the saver
  109.     * stop the saver
  110.     Note that before any processing is done, module configuration data is
  111.     loaded from the INI-files.
  112. */
  113. void    EXPENTRY SAVER_PROC(int function, HAB _hab, HWND hwndOwner, char *appname, void *buffer)
  114. {
  115. #if defined(__BORLANDC__)
  116.     extern ULONG __os2hmod;
  117.     hmodDLL = __os2hmod;
  118. #endif
  119.     hab = _hab;
  120.     application_name = appname;
  121.     // load all configuration data from INI-file
  122.     load_configuration_data();
  123.     switch(function){
  124.     case FUNCTION_CONFIGURE:
  125.         // call the configuration dialog
  126.         WinDlgBox(HWND_DESKTOP, hwndOwner, ConfigureDlgProc,
  127.           hmodDLL, IDD_CONFIGURE, application_name);
  128.         return;
  129.     case FUNCTION_STARTSAVER:
  130.         // start the saver
  131.         // get "low priority" state from supplied buffer (BOOL *)
  132.         low_priority = *((BOOL *)buffer);
  133.         // query size of screen
  134.         screenSizeX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  135.         screenSizeY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  136.         // register window class for the saver window
  137.         WinRegisterClass(hab, (PSZ)modulename,
  138.           (PFNWP)SaverWindowProc, 0, 0);
  139.         // create the saver window
  140.         hwndSaver = WinCreateWindow(HWND_DESKTOP, (PSZ)modulename,
  141.           (PSZ)NULL, WS_VISIBLE, 0, 0, screenSizeX, screenSizeY,
  142.           HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
  143.         return;
  144.     case FUNCTION_STOPSAVER:
  145.         // stop the saver
  146.         if(low_priority){
  147.             stop_priority_thread = TRUE;
  148.             DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, 0, tidPriority);
  149.             DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, 0, tidDraw);
  150.             DosWaitThread(&tidPriority, DCWW_WAIT);
  151. //              DosKillThread(tidPriority);    ***** kills thread 1 under OS/2 2.11
  152.         }
  153.         // tell drawing-thread to stop
  154.         stop_draw_thread = TRUE;
  155.         if(DosWaitThread(&tidDraw, DCWW_NOWAIT) == ERROR_THREAD_NOT_TERMINATED){
  156.             // if priority of drawing-thread was set to idle time
  157.             // priority, set it back to normal value
  158.             DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, PRTYD_MAXIMUM, tidDraw);
  159.             // wait until drawing-thread has ended
  160.             DosWaitThread(&tidDraw, DCWW_WAIT);
  161.         }
  162.  
  163.         if(hwndSaver != NULLHANDLE){
  164.             // move saver window to front
  165.             WinSetWindowPos(hwndSaver, HWND_TOP,
  166.               0, 0, 0, 0, SWP_ZORDER);
  167.             // destroy saver window
  168.             WinDestroyWindow(hwndSaver);
  169.             hwndSaver = NULLHANDLE;
  170.         }
  171.         return;
  172.     case FUNCTION_QUERYNAME:
  173.         // copy module name to supplied buffer (CHAR *)
  174.         strcpy(buffer, modulename);
  175.         return;
  176.     case FUNCTION_QUERYENABLED:
  177.         // copy "enabled" state to supplied buffer (BOOL *)
  178.         *((BOOL *)buffer) = configuration_data.enabled;
  179.         return;
  180.     case FUNCTION_SETENABLED:
  181.         // get new "enabled" state from supplied buffer (BOOL *)
  182.         configuration_data.enabled = *((BOOL *)buffer);
  183.         PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
  184.         return;
  185.     }
  186.  
  187.     // illegal function request
  188.     WinAlarm(HWND_DESKTOP, WA_ERROR);
  189.     return;
  190. }
  191.  
  192. #if !defined(__BORLANDC__)
  193. /*
  194.     _DLL_InitTerm
  195.     This procedure is called at DLL initialization and termination.
  196.     There should be no reason to alter the code.
  197. */
  198. ULONG    _DLL_InitTerm(HMODULE hmod, ULONG flag)
  199. {
  200.     switch(flag){
  201.     case 0: // initializing DLL
  202.         hmodDLL = hmod;
  203.         return 1;
  204.     case 1: // terminating DLL
  205.         return 1;
  206.     default:
  207.         // return error
  208.         return 0;
  209.     }
  210. }
  211. #endif
  212.  
  213. /*
  214.     ConfigureDlgProc
  215.     This is the dialog procedure for the module configuration dialog.
  216.     The dialog contains a check box for enabling/disabling the module
  217.     and two push buttons ("OK" and "Cancel") to close/cancel the dialog.
  218.     Since version 1.2, it contains a slider to set the animation speed;
  219.     if you don't want this slider, change the '#if 0' line in the
  220.     WM_INITDLG part of this dialog procedure.
  221.  
  222.     This is enough for simple saver modules, but can easily be expanded
  223.     for more saver modules that need more settings.
  224. */
  225. MRESULT EXPENTRY ConfigureDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  226. {
  227.     char    buf[sizeof(modulename)+20];
  228.     static    HWND    hwndEnabled;
  229.     static    HWND    hwndSpeed;
  230. /*
  231.     $$$$$ insert code here $$$$$
  232.     If you need additional data for dialog processing, insert it here.
  233.  
  234.     $$$$$ for example $$$$$
  235.     static    HWND    hwndCount;
  236. */
  237.     switch(msg){
  238.     case WM_INITDLG:
  239.         // set titlebar of the dialog window
  240.         // to "MODULENAME configuration"
  241.         strcpy(buf, modulename);
  242.         strcat(buf, " configuration");
  243.         WinSetWindowText(hwnd, (PSZ)buf);
  244.  
  245.         // get window handles of the dialog controls
  246.         // and set initial state of the controls
  247.         hwndEnabled = WinWindowFromID(hwnd, IDC_ENABLED);
  248.         WinSendMsg(hwndEnabled, BM_SETCHECK,
  249.           MPFROMSHORT(configuration_data.enabled), MPVOID);
  250.         hwndSpeed = WinWindowFromID(hwnd, IDC_SPEED);
  251.         WinSendMsg(hwndSpeed, SLM_SETTICKSIZE, MPFROM2SHORT(SMA_SETALLTICKS, 3), MPVOID);
  252.         WinSendMsg(hwndSpeed, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMLONG(configuration_data.animation_speed));
  253.         WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(0), MPFROMP("slow"));
  254.         WinSendMsg(hwndSpeed, SLM_SETSCALETEXT, MPFROMSHORT(4), MPFROMP("fast"));
  255. /*
  256.         $$$$$ insert code here $$$$$
  257.         Get window handles of your dialog controls.
  258.         Set initial state of your controls.
  259.  
  260.         $$$$$ for example $$$$$
  261.         hwndCount = WinWindowFromID(hwnd, IDC_COUNT);
  262.         WinSendMsg(hwndCount, SPBM_SETLIMITS, (MPARAM)CONFIGURATION_MAXIMUM_COUNT, (MPARAM)CONFIGURATION_MINIMUM_COUNT);
  263.         WinSendMsg(hwndCount, SPBM_SETCURRENTVALUE, MPFROMLONG(configuration_data.count), MPVOID);
  264. */
  265. #if 0        // if yoy don't use speed setting, replace the 0 with a 1
  266.         WinShowWindow(WinWindowFromID(hwnd, IDC_SPEED), FALSE);
  267.         WinShowWindow(WinWindowFromID(hwnd, IDC_SPEEDTEXT), FALSE);
  268. #endif
  269.         // return FALSE since we did not change the focus
  270.         return (MRESULT)FALSE;
  271.     case WM_COMMAND:
  272.         switch(SHORT1FROMMP(mp1)){
  273.         case IDC_OK:
  274.             // OK button was pressed. query the control settings
  275.             configuration_data.enabled = SHORT1FROMMR(WinSendMsg(hwndEnabled, BM_QUERYCHECK, MPVOID, MPVOID));
  276.             configuration_data.animation_speed = SHORT1FROMMR(WinSendMsg(hwndSpeed, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPVOID));
  277. /*
  278.             $$$$$ insert code here $$$$$
  279.             Query control settings of your controls.
  280.  
  281.             $$$$$ for example $$$$$
  282.             WinSendMsg(hwndCount, SPBM_QUERYVALUE, MPFROMP(&configuration_data.count), MPFROM2SHORT(0, SPBQ_DONOTUPDATE));
  283. */
  284.             // write all configuration data to INI-file
  285.             PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
  286.             // end dialog
  287.             WinDismissDlg(hwnd, TRUE);
  288.             return (MRESULT)0;
  289.         case IDC_CANCEL:
  290.             // dialog was cancelled; end it
  291.             WinDismissDlg(hwnd, FALSE);
  292.             return (MRESULT)0;
  293.         default:
  294.             return (MRESULT)0;
  295.         }
  296.     }
  297.     return WinDefDlgProc(hwnd, msg, mp1, mp2);
  298. }
  299.  
  300. /*
  301.     SaverWindowProc
  302.     This is the window procedure of the screen-size window that is
  303.     created when the saver starts.
  304.     There should be no reason to alter the code.
  305.     Note that we do not process WM_PAINT messages. They are forwarded to
  306.     the default window procedure, which just validates the window area
  307.     and does no drawing. All drawing to the window should be done in
  308.     the drawing-thread. Therefore, if you want to blank the screen before
  309.     drawing on it for instance, issue a WinFillRect call at the beginning
  310.     of your drawing-thread.
  311. */
  312. MRESULT EXPENTRY SaverWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  313. {
  314.     switch(msg){
  315.     case WM_CREATE:
  316.         // reset the "stop" flag
  317.         stop_draw_thread = FALSE;
  318.         // store window handle
  319.         hwndSaver = hwnd;
  320.         // get presentation space
  321.         hps = WinGetPS(hwnd);
  322.         // start the drawing-thread
  323. /*
  324.         $$$$$ note $$$$$
  325.         Some compilers use another parameter ordering for
  326.         _beginthread. The _beginthread call below works with EMX,
  327.         ICC and BCC. Check your compiler docs for other compilers.
  328. */
  329. #if defined(__BORLANDC__)
  330.         // for Borland C++
  331.         tidDraw = _beginthread(draw_thread, STACKSIZE, NULL);
  332. #elif defined(__EMX__) || defined(__IBMC__)
  333.         // for EMX and ICC
  334.         tidDraw = _beginthread(draw_thread, NULL, STACKSIZE, NULL);
  335. #endif
  336.         // create thread to control priority of drawing thread
  337.         if(low_priority){
  338.             stop_priority_thread = FALSE;
  339.             DosCreateThread(&tidPriority, (PFNTHREAD)priority_thread, 0, 2L, 1000);
  340.         }
  341.         return (MRESULT)FALSE;
  342.     case WM_DESTROY:
  343.         // release the presentation space
  344.         WinReleasePS(hps);
  345.         break;
  346.     case WM_PAINT:
  347.         // just validate the update area. all drawing is done
  348.         // in the drawing-thread.
  349.         return WinDefWindowProc(hwnd, msg, mp1, mp2);
  350.     }
  351.     return WinDefWindowProc(hwnd, msg, mp1, mp2);
  352. }
  353.  
  354. /*
  355.     priority_thread
  356.     This thread controls the priority of the drawing thread.
  357.     With these changes, if a saver module runs on low priority (this is
  358.     the default setting), it rises to normal priority twice a second
  359.     for 0.1 seconds. This should solve the problem that, when very
  360.     time-consuming processes were running, the module seemed not to become
  361.     active at all (in fact it became active, but did not get enough CPU
  362.     time to do its saver action).
  363.     There should be no reason to alter the code.
  364. */
  365. void    priority_thread(void *args)
  366. {
  367.     DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
  368.     for(;!stop_priority_thread;){
  369.         int    i;
  370.         DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, 0, tidDraw);
  371.         DosSleep(100);
  372.         DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, 0, tidDraw);
  373.         for(i=0;!stop_priority_thread && i<4;i++)
  374.             DosSleep(100);
  375.     }
  376. }
  377.  
  378. /*
  379.     load_configuration_data
  380.     Load all module configuration data from the INI-file into the
  381.     configuration_data structure, if not done already loaded.
  382. */
  383. void    load_configuration_data(void)
  384. {
  385.     if(configuration_data_loaded == FALSE){
  386.         // data not loaded yet
  387.         ULONG    size;
  388.         BOOL    fSuccess;
  389.         // get name of the saver module (stored as resource string)
  390.         if(WinLoadString(hab, hmodDLL, IDS_MODULENAME,
  391.           SAVER_NAME_MAXLEN, (PSZ)modulename) == 0){
  392.             // resource string not found. indicate error by
  393.             // setting module name to empty string (the name
  394.             // "" is interpreted as an error by SSDLL.DLL and
  395.             // the module does not show up in the list box).
  396.             strcpy(modulename, "");
  397.             return;
  398.         }
  399.         // load data from INI-file. the key name is the name of the
  400.         // saver module
  401.         size = sizeof(configuration_data);
  402.         fSuccess = PrfQueryProfileData(HINI_USER,
  403.           (PSZ)application_name, (PSZ)modulename,
  404.           (PSZ)&configuration_data, &size);
  405.         if(!fSuccess || size != sizeof(configuration_data) || configuration_data.version != MODULEVERSION){
  406.             // if entry is not found or entry has invalid size or
  407.             // entry has wrong version number, create a new entry
  408.             // with default values and write it to the INI-file
  409.             configuration_data.version = MODULEVERSION;
  410.             configuration_data.enabled = TRUE;
  411.             configuration_data.animation_speed = CONFIGURATION_DEFAULT_ANIMATIONSPEED;
  412. /*
  413.             $$$$$ insert code here $$$$$
  414.             If you have added data to the configuration_data
  415.             structure, insert code here to set the default
  416.             values for your data items.
  417.  
  418.             $$$$$ for example $$$$$
  419.             configuration_data.count = CONFIGURATION_DEFAULT_COUNT;
  420. */
  421.             PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
  422.         }
  423.         configuration_data_loaded = TRUE;
  424.     }
  425. }
  426.  
  427. /*
  428.     draw_thread
  429.     This is the drawing-thread.
  430.     You have a valid presentation space handle (hps), a valid window
  431.     handle (hwndSaver) and the configuration_data structure is loaded.
  432.     The screen size is stored in "screenSizeX" and "screenSizeY".
  433.     IMPORTANT NOTE 1:
  434.     You must check the "stop_draw_thread" flag regularly. If it is set,
  435.     free all resources you have allocated and call _endthread (or just
  436.     return) to end the drawing-thread.
  437.     IMPORTANT NOTE 2:
  438.     If the "low_priority" flag is NOT set (that means you run with
  439.     regular priority, sharing CPU usage with other programs), you should
  440.     call DosSleep(x) with "x" set at least to 1 as often as possible, to
  441.     allow other programs to do their work. A screen saver should not eat
  442.     up other program's CPU time!
  443.     IMPORTANT NOTE 3:
  444.     For some of the PM calls to work properly, your thread needs an
  445.     own HAB and maybe even a message queue. You have to get and release
  446.     both of them here if you use such PM calls.
  447.  
  448.     The following sample code is from the "Pyramids" module that comes
  449.     with the ScreenSaver distribution.
  450.     It selects a random color and a random point on the screen, then
  451.     draws lines in the selected color from each corner of the screen
  452.     to the selected point (looks somewhat like a pyramid).
  453.     It remembers a number of points (this number can be set in the
  454.     configuration dialog). Having filled the point memory, it redraws
  455.     the "oldest" visible pyramid in black. This has the effect that more
  456.     and more pixels on the screen get black, only a few constantly
  457.     changing colored lines remain.
  458. */
  459. void    draw_thread(void *args)
  460. {
  461. /*
  462.     $$$$$ replace or change the following example code $$$$$
  463.     int    i, j;
  464.     POINTL    pt_corner[4];
  465.     BOOL    point_buffer_filled;
  466.     POINTL    *pt;
  467.  
  468. //    HAB    drawingthread_hab = WinInitialize(0);
  469. //    HMQ    drawingthread_hmq = WinCreateMsgQueue(drawingthread_hab, 0);
  470.  
  471.     // random seed (needed for each thread)
  472.     srand(WinGetCurrentTime(hab));
  473.  
  474.     i = 0;
  475.     point_buffer_filled = FALSE;
  476.     // allocate stack memory for circular point buffer
  477.     pt = alloca(configuration_data.count * sizeof(POINTL));
  478.  
  479.     // set the corner coordinates
  480.     pt_corner[0].x = 0;
  481.     pt_corner[0].y = 0;
  482.     pt_corner[1].x = 0;
  483.     pt_corner[1].y = screenSizeY-1;
  484.     pt_corner[2].x = screenSizeX-1;
  485.     pt_corner[2].y = 0;
  486.     pt_corner[3].x = screenSizeX-1;
  487.     pt_corner[3].y = screenSizeY-1;
  488.  
  489.     while(!stop_draw_thread){
  490.         if(point_buffer_filled){
  491.             // redraw old pyramid in black
  492.             GpiSetColor(hps, CLR_BLACK);
  493.             for(j=0;j<4;j++){
  494.                 GpiMove(hps, &pt[i]);
  495.                 GpiLine(hps, &pt_corner[j]);
  496.             }
  497.         }
  498.  
  499.         // select random color
  500.         GpiSetColor(hps, ((unsigned)rand()) % 16);
  501.  
  502.         // select random point and store it in buffer
  503.         pt[i].x = ((unsigned)rand()) % screenSizeX;
  504.         pt[i].y = ((unsigned)rand()) % screenSizeY;
  505.  
  506.         // draw pyramid
  507.         for(j=0;j<4;j++){
  508.             GpiMove(hps, &pt[i]);
  509.             GpiLine(hps, &pt_corner[j]);
  510.         }
  511.  
  512.         // move circular buffer index
  513.         i++;
  514.         if(i == configuration_data.count)
  515.             point_buffer_filled = TRUE;
  516.         i %= configuration_data.count;
  517.  
  518.         // sleep if necessary
  519.         if(low_priority == FALSE)
  520.             DosSleep(1);
  521.  
  522.         // sleep if user requests slower animation
  523.         switch(configuration_data.animation_speed){
  524.         case 4: break;
  525.         case 3: DosSleep(10); break;
  526.         case 2: DosSleep(30); break;
  527.         case 1: DosSleep(50); break;
  528.         case 0: DosSleep(70); break;
  529.         }
  530.     }
  531.  
  532.     // free resources
  533.  
  534. //    WinDestroyMsgQueue(drawingthread_hmq);
  535. //    WinTerminate(drawingthread_hab);
  536.  
  537. */
  538.     _endthread();
  539. }
  540.