PDA

View Full Version : این کد text box چه مشکلی داره؟



s.kamal
یک شنبه 26 دی 1389, 21:51 عصر
دوستانی که یاد دارن خواهش میکنم کمک کنند
تا حالا text box های c# یا VB یا برنامه ویژوال های دیگه رو دیدین؟ دقیقا همون رو میخام تو محیط کنسول تحت داس c پیاده کنم. البته نه گرافیکی تو محیط textش. یه کادری باشه مثل این
+-----------------------------+
| kamal|
+-----------------------------+
که توش متن وارد کنم کمک کنید لطفا
کدی که نوشتم رو زیر میزارم ولی خیلی ناقصه
کمک کنید درستش کنم.

#include<stdio.h>
#include<conio.h>
//#include<graphics.h>

char EdStr[100];
int x,y,Ins, t,bd=0;
void init();
void push(char c);
void pop();
void isempty();
void isfull();
/*void movetol();
void movetor();
void home();
void end();
void draw();*/
char ch;
void main(){
int i;
clrscr();
init();
ch=getche();
while (ch!=13)
{
if (((ch>'a' && ch<'z') || (ch>'A' && ch<'Z'))) push(ch);
else if (ch==8) pop();
/*if (ch==75) s.movetol();
if (ch==77) s.movetor();
if (ch=='S') {s.movetor(); //del
s.pop();}
if (ch=='G') s.home();
if (ch=='O') s.end();
s.draw();*/
ch=getche();
}
}
//--------------------------------
void init()
{
int i;
gotoxy(30,10);
//bar(10,10,20,20);
printf("+");
for(i=1;i<20;i++)
{
printf("-");
delay(100);
}//؛
printf("+");
// printf("\v");
printf("|");

for(i=49;i>30;i--)
{
gotoxy(i,12);
printf("-");
delay(100);
} bar
gotoxy(31,11);
}
//-----------------------------
void push(char ch)
{
if(bd<100)
{
EdStr[bd]=ch;
bd++;
}
else
isfull();
/*for(i=0;i<bd;i++)
putchar(EdStr[i]);*/
}
//------------------------------
void pop()
{
int i;
ch=EdStr[bd];
if(bd>0)
{
bd--;
printf("\b");
/*for(i=0;i<bd;i++)
putchar(EdStr[i]);*/
}
else
{
isempty();
}
}
//------------------------------
void isempty()
{
gotoxy(20,5);
printf("poshte khali ast");
gotoxy(bd,11);
}
//------------------------------
void isfull()
{
gotoxy(20,5);
printf("poshte por shode ast");
gotoxy(bd,11);
}
//------------------------------

saber187518
سه شنبه 28 دی 1389, 00:07 صبح
با سلام
دوست عزیز کد شما به صورت زیر کار میکنه.
حالا اگه چیز دیگه ای هم هست بگو.


#include<stdio.h>
#include<conio.h>
//#include<graphics.h>
char EdStr[100];
int x,y,Ins, t,bd=0;
void init();
void push(char c);
void pop();
void isempty();
void isfull();
/*void movetol();
void movetor();
void home();
void end();
void draw();*/
char ch;
void main(){
int i;
clrscr();
init();
ch=getche();
while (ch!=13)
{
if (((ch>'a' && ch<'z') || (ch>'A' && ch<'Z'))) push(ch);
else if (ch==8) pop();
/*if (ch==75) s.movetol();
if (ch==77) s.movetor();
if (ch=='S') {s.movetor(); //del
s.pop();}
if (ch=='G') s.home();
if (ch=='O') s.end();
s.draw();*/
ch=getche();
}
}
//--------------------------------
void init()
{
int i;
gotoxy(30,10);
//bar(10,10,20,20);
printf("+");
for(i=1;i<20;i++)
{
printf("-");
//delay(100);
}//º
printf("+");
// printf("\v");
//printf("|");
for(i=49;i>30;i--)
{
gotoxy(i,12);
printf("-");
//delay(100);
} //bar
gotoxy(31,11);
}
//-----------------------------
void push(char ch)
{
if(bd<100)
{
EdStr[bd]=ch;
bd++;
}
else
isfull();
/*for(i=0;i<bd;i++)
putchar(EdStr[i]);*/
}
//------------------------------
void pop()
{
int i;
ch=EdStr[bd];
if(bd>0)
{
bd--;
printf("\b");
/*for(i=0;i<bd;i++)
putchar(EdStr[i]);*/
}
else
{
isempty();
}
}
//------------------------------
void isempty()
{
gotoxy(20,5);
printf("poshte khali ast");
gotoxy(bd,11);
}
//------------------------------
void isfull()
{
gotoxy(20,5);
printf("poshte por shode ast");
gotoxy(bd,11);
}
//------------------------------

یا علی...