home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 324_01 / sample.c < prev    next >
C/C++ Source or Header  |  1990-07-17  |  3KB  |  114 lines

  1. /*
  2.    HEADER:       ;
  3.    TITLE:        Sample code using Text Window Support Functions;
  4.    DATE:         07/17/1990;
  5.    SYSTEM:       MS-DOS;
  6.    FILENAME:     SAMPLE.C;
  7.    SEE-ALSO:     wgconio.h, wgconio.lib, wgconio.c, sample.exe;
  8.    AUTHORS:      Bill Giel;
  9.    COMPILERS:    TC;
  10. */
  11.  
  12. #include<stdlib.h>
  13.  
  14.  
  15. /* MAIN_MODULE must be defined in the first source file   */
  16. /* before calling WGCONIO.H header file. It should NOT be */
  17. /* defined in subsequent modules                          */
  18.  
  19. #define MAIN_MODULE 1
  20.  
  21. #include"wgconio.h"
  22.  
  23.  
  24. void main(void);
  25. void print_msg(void);
  26. void print_error(void);
  27.  
  28. void print_msg(void)
  29. {
  30.     wggotoxy(2,2);
  31.     wgcputs("Press Any Key To Continue...");
  32.     if(wggetch()==0)wggetch();
  33. }
  34.  
  35. void print_error(void)
  36. {
  37.         printf("Invalid Window or Allocation Failure\n");
  38.         exit(1);
  39. }
  40.  
  41. void main(void)
  42. {
  43.     /* Declare Pointers to dynamically allocated memory for windows */
  44.     char *p0,*p1,*p2,*p3,*p4,*p5;
  45.  
  46.     /* Declare and initiallize structs for windows */
  47.     struct wgwind w0 = {WHITE,RED,WHITE,BLUE,LIGHTGRAY,BLUE,5,5,75,20};
  48.     struct wgwind w1 = {YELLOW,BROWN,WHITE,BROWN,WHITE,BROWN,2,10,50,15};
  49.     struct wgwind w2 = {BLACK,GREEN,WHITE,BLUE,BLACK,GREEN,12,2,80,15};
  50.     struct wgwind w3 = {BLUE,CYAN,BLUE,CYAN,BLUE,CYAN,18,18,62,25};
  51.     struct wgwind w4 = {RED,BLACK,WHITE,BLUE,LIGHTGRAY,BLACK,20,7,60,18};
  52.     struct wgwind w5 = {WHITE,MAGENTA,WHITE,MAGENTA,LIGHTGRAY,MAGENTA,15,
  53.                     14,65,21};
  54.  
  55.     /* Declare structs for text information */
  56.     struct wgtext_info t0,t1,t2,t3,t4,t5;
  57.  
  58.     cursor_off();
  59.  
  60.  
  61.     /* Initiallize Window System...This MUST be done */
  62.     initiallize_WGW();
  63.  
  64.     /* Create first window */
  65.     if((p0=make_window("FIRST WINDOW",w0,
  66.                     &t0,SHADOW))==NULL)print_error();
  67.     print_msg();
  68.  
  69.     /* Create Remaining windows */
  70.     if((p1=make_window("SECOND WINDOW",w1,
  71.                     &t1,SHADOW))==NULL)print_error();
  72.     print_msg();
  73.  
  74.     if((p2=make_window("THIRD WINDOW",w2,
  75.                     &t2,SHADOW))==NULL)print_error();
  76.     print_msg();
  77.  
  78.     if((p3=make_window("FOURTH WINDOW",w3,
  79.                     &t3,SHADOW))==NULL)print_error();
  80.     print_msg();
  81.  
  82.     if((p4=make_window("FIFTH WINDOW",w4,
  83.                     &t4,SHADOW))==NULL)print_error();
  84.     print_msg();
  85.  
  86.     if((p5=make_window("SIXTH WINDOW",w5,
  87.                     &t5,SHADOW))==NULL)print_error();
  88.     print_msg();
  89.  
  90.  
  91.     /* Now remove windows in reverse order */
  92.  
  93.     restore_screen(w5,p5,t5,SHADOW);
  94.     if(wggetch()==0)wggetch();
  95.  
  96.     restore_screen(w4,p4,t4,SHADOW);
  97.     if(wggetch()==0)wggetch();
  98.  
  99.     restore_screen(w3,p3,t3,SHADOW);
  100.     if(wggetch()==0)wggetch();
  101.  
  102.     restore_screen(w2,p2,t2,SHADOW);
  103.     if(wggetch()==0)wggetch();
  104.  
  105.     restore_screen(w1,p1,t1,SHADOW);
  106.     if(wggetch()==0)wggetch();
  107.  
  108.     restore_screen(w0,p0,t0,SHADOW);
  109.  
  110.     size_cursor(6,7);
  111.  
  112. }
  113.  
  114.