home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 2.ddi / TOOLS.2 / EXAMPLES / WNEXAMPL.C < prev   
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.2 KB  |  77 lines

  1.     /* WNEXAMPL.C:  Simple example of Turbo C TOOLS window usage.   */
  2.  
  3. #include <bwindow.h>
  4.  
  5. int main()
  6. {
  7.     BWINDOW *pwin;
  8.     BORDER  bord;
  9.     WHERE   location;
  10.     int     mode,columns,act_page;
  11.     int     cursor_was_off,row,col,high,low;
  12.     char    response[5];
  13.     int     scan;
  14.  
  15.     /* Create the window structure in memory.                */
  16.  
  17.     pwin = wncreate(6,        /* Height of data area            */
  18.             15,     /* Width  of data area            */
  19.             SC_CYAN);    /* Attributes of data area        */
  20.     if (pwin == NIL)
  21.     return b_wnerr;     /* Quit if failure.            */
  22.                 /* (b_wnerr records the most        */
  23.                 /* recent window error.)        */
  24.  
  25.     /* Choose style of border.                        */
  26.  
  27.     bord.type = BBRD_SSSS | BBRD_TCT; /* Box drawn with single        */
  28.                 /*   lines, having a top centered   */
  29.                 /*   title.                */
  30.     bord.attr     = SC_MAGENTA;    /* Border will be magenta on black. */
  31.     bord.ttattr  = REVERSE;    /* Title will be black on white.    */
  32.     bord.pttitle = " A Window ";/* Text of the title.               */
  33.  
  34.     /* Choose where to display the window:  the active page on        */
  35.     /* the current display device.                    */
  36.  
  37.     location.dev    = scmode(&mode,&columns,&act_page);
  38.     location.page    = act_page;
  39.     location.corner.row = 10;
  40.     location.corner.col =  5;
  41.  
  42.     /* Retrieve former cursor position and size.            */
  43.  
  44.     cursor_was_off = sccurst(&row,&col,&high,&low);
  45.  
  46.     /* Actually display the window                    */
  47.  
  48.     if (NIL == wndsplay(pwin,&location,&bord))
  49.     return b_wnerr;     /* Quit if failure.            */
  50.  
  51.     /* Display a message on the window.                 */
  52.  
  53.     wnprintf("Hello, world!  (Press ENTER to continue) ");
  54.     if (b_wnerr)
  55.     return b_wnerr;     /* Quit if failure.            */
  56.  
  57.     /* Await a response from the user, echoing keystrokes to the    */
  58.     /* window.                                */
  59.  
  60.     wnquery(response,
  61.         sizeof(response),
  62.         &scan);
  63.     if (b_wnerr)
  64.     return b_wnerr;     /* Quit if failure.            */
  65.  
  66.     /* Remove the window & restore the screen and cursor.        */
  67.  
  68.     wnremove(pwin);
  69.     if (b_wnerr)
  70.     return b_wnerr;     /* Quit if failure.            */
  71.  
  72.     sccurset(row,col);
  73.     scpgcur(cursor_was_off,high,low,CUR_NO_ADJUST);
  74.  
  75.     return wndstroy(pwin);    /* Clean up data structures.        */
  76. }
  77.