PDA

View Full Version : سوال: چگونه یک منو بسازم؟



se_sol
یک شنبه 12 اردیبهشت 1389, 21:55 عصر
با استفاده از چه دستوراتی میتونم یه برنامه بنویسم که محیطی داشته باشه که بشه توش چیزی نوشت و اعمال cut,copy,paste ,save روش انجام بشه.... و چه جوری میتونم برای این برنامه منو بسازم؟

baran_mehr
یک شنبه 12 اردیبهشت 1389, 22:38 عصر
سلام
فکر کنم تو قسمت سی (http://barnamenevis.org/forum/forumdisplay.php?s=&daysprune=-1&f=45) بتونی چیزای خوبی پیدا کنی تو قسمت گرافیکش

baran_mehr
یک شنبه 12 اردیبهشت 1389, 22:41 عصر
این کدم یه امتحان کن یه منوی ساده هست

#include<conio.h>
#include<dos.h>
#include<string.h>

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;j<y_start+y_size;j++){
delay(effect_time);
if((j==y_start+2)&&(*title!='\0')){
gotoxy(x_start,j);
putch(199);
gotoxy(x_start+x_size,j);
putch(182);
}
else{
gotoxy(x_start,j);
putch(186);
gotoxy(x_start+x_size,j);
putch(186);
}
}
gotoxy(x_start,y_start+y_size);
putch(200);
gotoxy(x_start+x_size,y_start+y_size);
putch(188);
for(j=x_start+1;j<x_start+x_size;j++){
delay(effect_time);
gotoxy(j,y_start);
putch(205);
if(*title!='\0'){
gotoxy(j,y_start+2);
putch(196);
}
gotoxy(j,y_start+y_size);
putch(205);
}
textcolor(choice_color);
if(cho_def>val_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<val_line)){
gotoxy(x_start+2,y_lines[rtn-1]);
putch(' ');
rtn++;
gotoxy(x_start+2,y_lines[rtn-1]);
putch(16);
}

}while(ch_key!=13);
textcolor(choice_color-128);
gotoxy(x_start+2,y_lines[rtn-1]);
putch(4);

gotoxy(x_start,y_start+y_size+1);
normvideo();
_setcursortype(_NORMALCURSOR);
return rtn;

}

se_sol
دوشنبه 13 اردیبهشت 1389, 11:49 صبح
وای مرسی...:لبخندساده: