home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / 1001132a < prev    next >
Text File  |  1991-11-19  |  1KB  |  58 lines

  1. #include "window.h"
  2. #include <ctype.h>
  3. #include "vstream.h"
  4.  
  5. // Make  sure user really wants to quit
  6. int cfmexit(void)
  7.    {
  8.    int c;
  9.    boxwin promptwin(30,12,50,14,0x70,1);
  10.    conout<<"Really   quit? (Y/N)";
  11.    while (1)
  12.       {
  13.       c=getche();
  14.       if (!c)  getch();  // ignore Function keys
  15.       c=toupper(c);
  16.       if (c=='Y') return 1;
  17.       if (c=='N') return 0;
  18.       }
  19.    }
  20.  
  21.  
  22. // Main  routine
  23. main()
  24.    {
  25. /* make  main window */
  26.    boxwin mainwindow(2,20,78,23,0x70);
  27.    win *w[4];
  28.    conout<<"Welcome to the WINDOWS++ demo.\n";
  29.    conout<<"Initializing windows...\n";
  30.    w[3]=new boxwin(60,2,78,10,0x70);
  31.    conout<<"Window   #4";
  32.    w[2]=new boxwin(40,2,70,10,0x3F);
  33.    conout<<"Window   #3";
  34.    w[1]=new boxwin(20,2,50,10,0x17);
  35.    conout<<"Window   #2";
  36.    w[0]=new boxwin   (2,2,30,10,7);
  37.    conout<<"Window   #1";
  38.    mainwindow.maketop();
  39.    while (1)
  40.       {
  41.       int c;
  42.       conout<<
  43.         "Press 1-4 to   select window or <Esc> to quit\n";
  44.       c=getch();
  45.       if (c==27)
  46.          if (cfmexit()) break; else continue;
  47.       if (c<'1'||c>'4')
  48.          {
  49.          conout<<"Unknown window!\n";
  50.          continue;
  51.          }
  52.       conout<<"Activating window "<<(char)c<<'\n';
  53.       w[c-'1']->maketop();
  54.       mainwindow.maketop();
  55.       }
  56.    for (int i=0;i<4;i++) delete w[i];
  57.    }
  58.