home *** CD-ROM | disk | FTP | other *** search
- /**
- * TCWIN.C Example of Turbo C TOOLS window support of the
- * Turbo C text window.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
-
- #include <bwindow.h>
- #include <bkeys.h>
- #include <conio.h>
-
- int main()
- {
- BWINDOW *pwin;
- BORDER bord;
- WHERE location;
- int mode,columns,act_page;
- int cursor_was_off,row,col,high,low;
- int scan;
-
- /* Create the window structure in memory. */
-
- pwin = wncreate(6, /* Height of data area */
- 40, /* Width of data area */
- SC_CYAN); /* Attributes of data area */
- if (pwin == NIL)
- return b_wnerr; /* Quit if failure. */
- /* (b_wnerr records the most */
- /* recent window error.) */
-
- /* Choose style of border. */
-
- bord.type = BBRD_SSSS | BBRD_TCT; /* Box drawn with single */
- /* lines, having a top centered */
- /* title. */
- bord.attr = SC_MAGENTA; /* Border will be magenta on black. */
- bord.ttattr = REVERSE; /* Title will be black on white. */
- bord.pttitle = " A Window ";/* Text of the title. */
-
- /* Choose where to display the window: the active page on */
- /* the current display device. */
-
- location.dev = scmode(&mode, &columns, &act_page);
- location.page = act_page;
- location.corner.row = 10;
- location.corner.col = 5;
-
- /* Retrieve former cursor position and size. */
-
- cursor_was_off = sccurst(&row, &col, &high, &low);
-
- /* Actually display the window. */
-
- if (NIL == wndsplay(pwin, &location, &bord))
- return b_wnerr; /* Quit if failure. */
-
- /* Display two messages on the window. */
-
- wncurmov(0, 0);
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
-
- wnprintf("This is the first line.\n");
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
- wnprintf("This is the second line.\n");
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
- /* Now use the Turbo C text window functions to reposition the */
- /* cursor and insert a new blank line. Note that Turbo C TOOLS */
- /* window coordinates use (0, 0) as the upper left corner, */
- /* whereas Turbo C uses (1, 1). */
-
- gotoxy(1, 2);
- insline();
- cprintf("This line is courtesy of cprintf().");
-
- /* Now synchronize the window's memory image with the screen. */
-
- wnrevupd();
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
- wncurmov(4, 0);
- wnprintf("Press Enter or Esc to quit:");
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
- /* Poll the keyboard till the user presses Enter or ESC. */
-
- scan = 0;
- while ((scan != KB_S_N_ENTER) && (scan != KB_S_N_ESC))
- kbgetkey(&scan);
-
- /* Remove the window & restore the screen and cursor. */
-
- wnremove(pwin);
- if (b_wnerr)
- return b_wnerr; /* Quit if failure. */
-
- sccurset(row, col);
- scpgcur(cursor_was_off, high, low, CUR_NO_ADJUST);
-
- return wndstroy(pwin); /* Clean up data structures. */
- }