Listing 8 (wintest.cpp)

#include "window.h"
#include <ctype.h>
#include "vstream.h"

// Make sure user really wants to quit
int cfmexit(void)
   {
   int c;
   boxwin promptwin(30,12,50,14,0x70,1);
   conout<<"Really   quit? (Y/N)";
   while (1)
      {
      c:getche();
      if (!c) getch();   // ignore Function keys
      c:toupper(c);
      if (c=='Y') return 1;
      if (c=='N') return 0;
      }
   }


// Main routine
main()
   (
/* make main window */
   boxwin mainwindow(2,20,78,23,0x70);
   win *w[4];
   conout<<"Welcome to the WINDOWS++ demo.\n";
   conout<<"Initializing windows...\n";
   w[3]=new boxwin(60,2,78,10,0x70);
   conout<<"Window   #4";
   w[2]=new boxwin(40,2,70,10,0x3F);
   conout<<"Window   #3";
   w[1]=new boxwin(20,2,50,10,0x17);
   conout<<"Window   #2";
   w[0]=new boxwin  (2,2,30,10,7);
   conout<<"Window   #1";
   mainwindow.maketop();
   while (1)
      {
      int c;
      conout<<
        "Press 1-4 to  select window or <Esc> to quit\n";
      c=getch();
      if (c==27)
        if (cfmexit()) break; else continue;
      if (c<'l' ||c>'4')
        {
        conout<<"Unknown window!\n";
        continue;
        }
      conout<<"Activating window "<<(char)c<<'\n';
      w[c-'l']->maketop();
      mainwindow.maketop();
      }
   for (int i:0=i<4;i++) delete w[i];
   }

// End of File