# include <>
# include <>
# include <>
# include <>
# include <>
# include <>
int video_mode(void);
void goto_xy(int x,int y);
void set_v_ptr();
void write_char(int x,int y,char ch,int attrib);
void write_string(int x,int y,char *p,int attrib);
background color.
const enum clr
{
black,blue,green,cyan,red,magenta,brown,lightgray,darkgray,lightblue,lightgreen,lightcyan,lightred,lightmagenta,yellow,white,blink=128
};
char far *vid_mem;
class wintype
{
int leftx;
int upy;
int rightx;
int downy;
int border;
int active;
char *title;
int curx,cury;
char *buf;
char color;
void save_screen();
void restore_screen();
void draw_border();
void display_title();
public:
wintype(int lx,int uy,int rx,int ly,int b=1,char *mess="");
wintype()
{
winremove();delete buf;
}
void winput();
void winremove();
int winputs(char *s);
int winxy(int x,int y);
void wingets(char *s);
int wingetche();
void wincls();
void wincleol();
void setcolor(char c)
{
color=c;
}
char getcolor()
{
return color;
}
void setbkcolor(char c)
{
color=color | (c<<4);
}
char getbkcolor()
{
return (color>>4)&127;
}
friend wintype&operator<<(wintype&o,char *s);
frient wintype&operator>>(wintype&o,char *s);
};
wintype::wintype(int lx,int uy,int rx,int ly,int b, char *mess)
{
if(lx<0)lx=0;
if(rx>79)rx=79;
if(uy<0)uy=0;
if(ly>24)ly=24;
leftx=lx;
upy=uy;
rightx=rx;
downy=ly;
border=b;
title=mess;
active=0;
curx=cury=0;
buf=new char[2*(rightx-leftx+1)*(downy-upy+1)];
if(!buf)
{
cout<<"Allocation error\n";
exit(1);
}
color=white;
}
void wintype::winput()
{
if(!active)
{
save_screen();
active=1;
}
else return;
if(border)draw_border();
display_title();
goto_xy(leftx+curx=1;upy+cury+1);
}
void wintype::winremove()
{
if(!active)return;
restore_screen();
active=0;
}
void wint
C 语言窗口程序 来自淘豆网m.daumloan.com转载请标明出处.