home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRO1.ZIP / MTDEMO.C < prev    next >
Text File  |  1989-01-02  |  2KB  |  118 lines

  1. #include "pro.h"
  2. #include "xglobals.h"
  3. #include "colors.h"
  4. #include "vs.h"
  5. #include "video.h"
  6. #include "werrors.h"
  7. #include <process.h>
  8. #include <stdlib.h>
  9. #include <malloc.h>
  10. #include <string.h>
  11.  
  12. void far p1(void far *);
  13. void far p2(void far *);
  14. void far p3(void far *);
  15.  
  16. #define STACKSIZE     2048
  17. #define NUMWDWS     3
  18.  
  19. main()
  20. {
  21.     void far *stackbottom[NUMWDWS * 3];
  22.     int i;
  23.     unsigned handle[NUMWDWS];
  24.     char name[3];
  25.  
  26.     v_gotoxy(0,24);
  27.     printf("Press any key to stop ...");
  28.  
  29.     wn_init();
  30.  
  31.     /* output to virtual screens */
  32.     for(i = 0; i < NUMWDWS; i++) {
  33.         stackbottom[i] = _fmalloc(STACKSIZE);
  34.         sprintf(name,"%d",i);
  35.         handle[i] = wn_createw(20,24, (i * (physical_columns/NUMWDWS))+1,1,1,1,10,12,FALSE,HEAD_ON,strdup(name),NULL);
  36.         wn_openw(handle[i]);
  37.         _beginthread(p1,stackbottom[i],STACKSIZE,(void far *) handle[i]);
  38.     }
  39.  
  40.     /* move windows */
  41.     for(i = 0; i < NUMWDWS; i++) {
  42.         stackbottom[i+NUMWDWS] = _fmalloc(STACKSIZE);
  43.         _beginthread(p2,stackbottom[i+NUMWDWS],STACKSIZE,(void far *) handle[i]);
  44.     }
  45.  
  46.     /* scroll virtual screens */
  47.     for(i = 0; i < NUMWDWS; i++) {
  48.         stackbottom[i+NUMWDWS*2] = _fmalloc(STACKSIZE);
  49.         _beginthread(p3,stackbottom[i+NUMWDWS*2],STACKSIZE,(void far *) handle[i]);
  50.     }
  51.     getch();
  52.     v_gotoxy(oldx,oldy);
  53.     wn_restorescr();
  54. }
  55.  
  56. void p1(v)
  57. void far *v;
  58. {
  59.     int count = 0;
  60.     while(1) {
  61.         REQ;
  62.         vs_printf((unsigned) v,0,white,black,"count = %d\n",count++);
  63.         CLR;
  64.     }
  65. }
  66.  
  67. void p2(v)
  68. void far *v;
  69. {
  70.     int a;
  71.     unsigned handle = (unsigned) v;
  72.  
  73.     a = 1;
  74.     while(1) {
  75.         switch(a) {
  76.             case 1 :
  77.                 if (wn_movew(handle, 0, 1) == MODIFIED) a = 2;
  78.                 break;
  79.             case 2 :
  80.                 if (wn_movew(handle, 1, 0) == MODIFIED) a = 3;
  81.                 break;
  82.             case 3 :
  83.                 if (wn_movew(handle, 0, -1) == MODIFIED) a = 4;
  84.                 break;
  85.             case 4 :
  86.                 if (wn_movew(handle, -1, 0) == MODIFIED) a = 1;
  87.                 break;
  88.         }
  89.     }
  90. }
  91.  
  92. void p3(v)
  93. void far *v;
  94. {
  95.     int a;
  96.     unsigned handle = (unsigned) v;
  97.  
  98.     a = 1;
  99.     while(1) {
  100.         switch(a) {
  101.             case 1 :
  102.                 if (wn_scrollvs(handle, 0, 0, 1) == MODIFIED) a = 2;
  103.                 break;
  104.             case 2 :
  105.                 if (wn_scrollvs(handle, 0, 1, 0) == MODIFIED) a = 3;
  106.                 break;
  107.             case 3 :
  108.                 if (wn_scrollvs(handle, 0, 0, -1) == MODIFIED) a = 4;
  109.                 break;
  110.             case 4 :
  111.                 if (wn_scrollvs(handle, 0, -1, 0) == MODIFIED) a = 1;
  112.                 break;
  113.         }
  114.         wn_sync_tw_to_vs(handle,0);
  115.     }
  116. }
  117.  
  118.