subwin

subwin的函数原型WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x)。

#include <curses.h>

subwin() creates and returns a pointer to a new window with the given number of lines, nlines, and columns, ncols. The window is at position (begin_y, begin_x) on the screen. (This position is relative to the screen, and not to the window orig.) The window is made in the middle of the window orig, so that changes made to one window will affect both windows. The subwindow shares memory with the window orig. When using this routine, it is necessary to call touchwin() or touchline() on orig before calling wrefresh() on the subwindow.

Routines that return an integer return the integer ERR upon failure and OK (SVr4 only specifies "an integer value other than ERR") upon successful completion.

#include <ocurses.h>

main()

{

WINDOW *sub;

initscr();

box(stdscr,'w','w');

/* See the curses(3ocurses) manual page for box */

mvwaddstr(stdscr,7,10,"------- this is 10,10");

mvwaddch(stdscr,8,10,'|');

mvwaddch(stdscr,9,10,'v');

sub = subwin(stdscr,10,20,10,10);

box(sub,'s','s');

wnoutrefresh(stdscr);

wrefresh(sub);

endwin();

}

相关词汇