#include #include #include int get_menu(char*,char[]="",int=1,int=15,int=11,int=12,int=1,int=14); void main(){ int rtn; do{ clrscr(); rtn=get_menu("Yes,No","Do you exit?",2); }while(rtn!=1); } int get_menu(char *str,char *title,int cho_def,int effect_time,int text_color,int title_color,int border_color,int choice_color){ if(*str=='\0') return 0; int j,rtn=1,val_line=0,x_start,y_start,x_size,y_size,y_lines[100]; char ch_key; struct text_info screen_info; choice_color+=128; gettextinfo(&screen_info); x_start=screen_info.curx; y_start=screen_info.cury; x_size=screen_info.curx; y_size=screen_info.cury; _setcursortype(_NOCURSOR); //print text of menu: textcolor(text_color); if(*title) cprintf("\n\n\n"); else cprintf("\n"); while(*str){ delay(effect_time); if(val_line==0){ gotoxy(x_start+4,wherey()); val_line++; y_lines[val_line-1]=wherey(); } if((*str==',')){ if(*(str+1)==','){ cprintf(","); str+=2; } else{ gotoxy(x_start+4,wherey()+2); val_line++; y_lines[val_line-1]=wherey(); str++; } } else{ putch(*str); str++; } x_size=wherex()>x_size ? wherex() : x_size; } y_size=wherey()>y_size ? wherey() : y_size; x_size-=x_start; y_size-=y_start; y_size++; textcolor(title_color); if(*title){ x_size=strlen(title)+5>x_size ? strlen(title)+5 : x_size; gotoxy(((x_size+2)-strlen(title)+1)/2,y_start+1); cprintf("%s",title); } //Draw border: textcolor(border_color); gotoxy(x_start,y_start); putch(201); gotoxy(x_start+x_size,y_start); putch(187); for(j=y_start+1;jval_line) rtn=val_line; else if(cho_def<1) rtn=1; else rtn=cho_def; do{ gotoxy(x_start+2,y_lines[rtn-1]); putch(16); ch_key=getch(); if(ch_key==0) ch_key=getch(); if((ch_key==72)&&(rtn>1)){ gotoxy(x_start+2,y_lines[rtn-1]); putch(' '); rtn--; gotoxy(x_start+2,y_lines[rtn-1]); putch(16); } else if((ch_key==80)&&(rtn