home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / msjournl / msjv3_6.arc / VIDEO.ARC / DEMO.C < prev    next >
C/C++ Source or Header  |  1988-08-10  |  3KB  |  93 lines

  1. /* ==================================================================
  2.               DEMO.C - Program demonstrating the use of 
  3.               video functions.
  4.  
  5.               Copyright (c) 1988 Microsoft Systems Journal
  6.  
  7.               Compile with:  cl /c demo.c
  8.                              link /noi demo+cvideo+asmvideo;
  9. ================================================================== */
  10.  
  11. #include "video.h"
  12. #include <time.h>
  13.  
  14. struct VideoInfo video;
  15. int buffer[3][510];
  16.  
  17. main()
  18. {
  19.    char TextColor = 0x07;
  20.    char BorderColor = 0x0F;
  21.    char WinColor1, WinColor2, WinColor3;
  22.    int i, j;
  23.  
  24.    /* ----- Initialize video structure ----- */
  25.    GetVideoParms(&video);
  26.  
  27.    /* ----- Set attributes for monochrome or color ----- */
  28.    if (video.ColorFlag) {
  29.        WinColor1 = 0x1F;
  30.        WinColor2 = 0x4F;
  31.        WinColor3 = 0x6F;
  32.    }
  33.    else {
  34.        WinColor1 = 0x0F;
  35.        WinColor2 = 0x70;
  36.        WinColor3 = 0x0F;
  37.    }
  38.  
  39.    /* ----- Clear the screen and fill it with text ----- */
  40.    ClrScr(TextColor, &video);
  41.    for (i=0; i<video.rows; i++)
  42.        for (j=0; j<=52; j+=26)
  43.            DispString("Microsoft Systems Journal", i, j, TextColor, 
  44.                       &video);
  45.    delay(2.0);
  46.  
  47.    /* ----- Open a window ----- */
  48.    SaveRegion(5, 2, 14, 34, buffer[0], &video);
  49.    ClrRegion(6, 3, 13, 33, WinColor1);
  50.    TextBox(5, 2, 14, 34, BorderColor, &video);
  51.    for (i=6; i<14; i++)
  52.        DispString("Open the first window here...", i, 4, WinColor1, 
  53.                   &video);
  54.    delay(2.0);
  55.  
  56.    /* ----- Open a second window ----- */
  57.    SaveRegion(2, 48, 12, 74, buffer[1], &video);
  58.    ClrRegion(3, 49, 11, 73, WinColor2);
  59.    TextBox(2, 48, 12, 74, BorderColor, &video);
  60.    for (i=3; i<12; i++)
  61.        DispString("Then the second here...", i, 50, WinColor2, 
  62.                   &video);
  63.    delay(2.0);
  64.  
  65.    /* ----- Open a third window overlapping the first two ----- */
  66.    SaveRegion(9, 25, 22, 60, buffer[2], &video);
  67.    ClrRegion(10, 26, 21, 59, WinColor3);
  68.    TextBox(9, 25, 22, 60, BorderColor, &video);
  69.    for (i=10; i<22; i++)
  70.        DispString("And finally a third window here.", i, 27,
  71.                   WinColor3, &video);
  72.    delay(4.0);
  73.  
  74.    /* ----- Close all windows and exit ----- */
  75.    RestRegion(9, 25, 22, 60, buffer[2], &video);
  76.    delay(1.0);
  77.    RestRegion(2, 48, 12, 74, buffer[1], &video);
  78.    delay(1.0);
  79.    RestRegion(5, 2, 14, 34, buffer[0], &video);
  80.    delay(1.0);
  81.    ClrScr(TextColor, &video);
  82. }
  83. /* ----- Timed delay function ----- */
  84. delay(double sec)
  85. {
  86.    time_t StartTime, EndTime;
  87.  
  88.    time(&StartTime);
  89.    time(&EndTime);
  90.    while (difftime(EndTime, StartTime) < sec)
  91.        time(&EndTime);
  92. }
  93.