home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / c / cwl30 / cwl3demo / cwlfunc1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-24  |  2.0 KB  |  59 lines

  1. #include "cwldemo.h"
  2.  
  3. int WinCreate (POPUP_MENU_PTR p, int sel)
  4. {
  5.   WPOINTER cw, tw;
  6.   char buf[20];
  7.   int i, rand1, rand2, rand3, rand4, rand5, rand6, rand7, j;
  8.   FLUSH_KEYBOARD();
  9.   cw = WindowInitialize(DESKTOP_WINDOW,
  10.                         BORDER,0,0,40,2,BLACKONCYAN,BLACKONCYAN,SINGLEBOX);
  11.   WindowWriteCenterString(cw,"You can create windows easily",0);
  12.   WindowWriteCenterString(cw,"with borders...",1);
  13.   WindowCenter(cw,VERTCENTER | HORIZCENTER);
  14.   WindowDisplay(cw,1,NOEFFECT);
  15.  
  16.   delay_approx(5000);
  17.  
  18.   WindowClose(cw,NOEFFECT);
  19.   cw = WindowInitialize(DESKTOP_WINDOW,
  20.                         NOBORDER,0,0,40,1,BLACKONCYAN,BLACKONCYAN,SINGLEBOX);
  21.   WindowWriteCenterString(cw,"...and without borders...",0);
  22.   WindowCenter(cw,VERTCENTER | HORIZCENTER);
  23.   WindowDisplay(cw,1,NOEFFECT);
  24.   delay_approx(5000);
  25.   WindowClose(cw,NOEFFECT);
  26.  
  27.   cw = WindowInitialize(DESKTOP_WINDOW,
  28.                         BORDER,0,0,50,1,BLACKONCYAN,BLACKONCYAN,SINGLEBOX);
  29.   WindowWriteCenterString(cw,"You can create overlapping windows ...",0);
  30.   WindowCenter(cw,VERTCENTER | HORIZCENTER);
  31.   WindowDisplay(cw,1,NOEFFECT);
  32.   delay_approx(3000);
  33.   for (i = 0; i < 50; i++)
  34.   {
  35.     rand1 = rand() % (CWLscreen_rows - 1);
  36.     rand2 = rand() % (CWLscreen_cols - 1);
  37.     rand3 = (rand() % (CWLscreen_cols - 1)) + 1;
  38.     rand4 = (rand() % (CWLscreen_rows - 1)) + 1;
  39.     rand5 = rand() % 16;
  40.     rand6 = rand() % 16;
  41.     wTemp[i] = WindowInitialize(DESKTOP_WINDOW, BORDER, rand1, rand2,
  42.                                 rand3, rand4, rand5, rand6, SINGLEBOX);
  43.     if (!wTemp[i])
  44.       break;
  45.     sprintf(buf,"Window %d",i + 1);
  46.     WindowWriteCenterString(wTemp[i],buf,rand4 / 2);
  47.     WindowDisplay(wTemp[i],1,NOEFFECT);
  48.   }
  49.   delay_approx(5000);
  50.   WindowClear(cw);
  51.   WindowWriteCenterString(cw,"Press a key to clear the windows...",0);
  52.   WindowDisplay(cw,1,NOEFFECT);
  53.   GET_KEY();
  54.   for (j = i-1; j >= 0; j--)
  55.     WindowClose(wTemp[j],NOEFFECT);
  56.   WindowClose(cw,NOEFFECT);
  57.   return POPUP_CONTINUE;
  58. }
  59.