基本设计要求:在C的文本显示方式下,绘制七个高亮度显示的层叠小窗口,每个窗口颜色各不相同,并显示相应的颜色文字。输入1-7中任一数字,可使相应的窗口凸显出来。相关函数:textcolor(),window(),clrscr(),cputs()等。七种眼色的窗口层叠,从上到下分别是lightgray brown magenta red cyan green blue ,谢谢`由于我不懂源程序代码,所以请求大虾赐教
你参考一下下面的程序吧,在Win-TC运行的可按任意键,Alt+x退出,Alt+F,Alt+E,Alt+S激活菜单。#include "conio.h"#include "graphics.h"#define closegr closegraph#include <dos.h> #include <stdio.h> #ifdef __cplusplus #define __ARGU ... #else #define __ARGU #endif char key;int ok=0;void initgr(void) /* BGI初始化 */{ int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */ registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */ initgraph(&gd, &gm, "");}/* 在图形模式下的清屏 */void cls(){ setfillstyle(SOLID_FILL,0); setcolor(0); bar(0,0,640,480);}/*游戏中出现的文字*/void txt(int a,int b,char *txt,int font,int color){ setcolor(color); settextstyle(0,0,font); outtextxy(a,b,txt);}/*在图形模式下的高级清屏*/void clscr(int a,int b,int c,int d,int color){ setfillstyle(SOLID_FILL,color); setcolor(color); bar(a,b,c,d);}/*windows 绘制*/void win(int a,int b,int c,int d,int bgcolor,int bordercolor){ clscr(a,b,c,d,bgcolor); setcolor(bordercolor); line(a,b,c,b); line(a,b,a,d); line(a,d,c,d); line(c,b,c,d);}void interrupt int60 (__ARGU) /*中断服务函数*/{switch(key) { case 0x01b: exit(1); case 0x021: win(52,72,150,180,11,15); txt(60,60,"File",1,4); txt(60,82,"Open",1,5); txt(60,100,"Save",1,5); txt(60,118,"Close",1,5); getch(); win(52,72,578,418,3,15); txt(60,60,"File",1,15); break; case 0x012: win(110,72,208,180,11,15); txt(110,60,"Edit",1,4); getch(); win(52,72,578,418,3,15); txt(110,60,"Edit",1,15); break; case 0x01f: win(156,72,258,180,11,15); txt(156,60,"Search",1,4); getch(); win(52,72,578,418,3,15); txt(156,60,"Search",1,15); break; case 0x02d: exit(1); default : ok=1; break; } }void install (void interrupt (*fadd)(__ARGU),int num) /*安装中断*/ { disable(); /*关闭中断*/ setvect(num, fadd); /*设置中断*/ enable(); /*开放中断*/ } int main(void){ int x,y; int i; char text[2]={'\0','\0'}; char p; initgr(); /* BGI初始化 */ cls(); clscr(50,30,580,420,15); win(52,32,578,418,3,15); /*绘制总背景*/ win(52,32,578,52,9,15); /*绘制标题栏*/ win(52,52,578,72,3,15); /*绘制菜单栏*/ win(561,35,575,49,4,12); /*绘制关闭钮*/ win(544,35,558,49,11,15); /*绘制最大化钮*/ win(527,35,541,49,11,15); /*绘制最小化钮*/ txt(60,38,"notitle-Note",1,15); /*标题栏文字*/ txt(565,39,"X",1,15); txt(548,39,"O",1,4); txt(530,39,"_",1,4); txt(60,60,"File",1,15); /*以下为菜单栏文字*/ txt(110,60,"Edit",1,15); txt(156,60,"Search",1,15); /*****此部分添加你自己的代码,例如 line(25, 25, 220, 220); circle(100, 100, 50); 等等*****/ install (int60,0x60);/*将int60函数安装到0x60中断*/ while(1) { geninterrupt (0x60); for(i=0,x=53,y=74;i<2176;i++) { text[0]=getch(); key=text[0]; geninterrupt (0x60); if(ok==1) { setcolor(5); outtextxy(x,y,text); } if(x>=555) { x=53; y=y+10; } else x=x+8; }} getch(); /* 暂停一下,看看前面绘图代码的运行结果 */ closegr(); /* 恢复TEXT屏幕模式 */ return 0;}