PDA

View Full Version : سوال: میخوام توی برنامم copy و paste کارکنه چکار کنم؟



sir_ams
پنج شنبه 17 دی 1388, 14:06 عصر
البته باید بدونم چطوری shift+جهت ها کار میکنه کمکم کنید؟هینم برنامم:
include<dos.h>
#include<process.h>
#include<string.h> // for various functions of strings like gets or puts
#include<fstream> // for files
#include<stdio.h>
#include<iostream>
#include<conio.h>
#include<windows.h>
void gotoxy(int x,int y)
{
HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
if (INVALID_HANDLE_VALUE != hConsole)
{
COORD pos = {x, y};
SetConsoleCursorPosition( hConsole, pos );
}
}
void starting();
void typing();
void save();
void openfile(char *);
void newfile(char *);
void print(char i[],int x,int y);
char ch;
int i;
char s[20];
char xs[20];
char ys[20];
using namespace std;
int main()
{
system("color AC");
printf("PRODUCT BY sir_ams\n");
starting();
typing();
getch();
}
void starting(){
for(int i=0 ;i<45;i++)
{if(i==0||i==44)
printf(" ");
else if(i==4)
printf(" ctrl+O(Open file)");
else if(i==24)
printf(" ctrl+n(New file)");
else
printf("*");}
gotoxy(80,24); printf(" ");
for(int j=0 ;j<37;j++)
{if(j==0||j==47)
printf(" ");
else if(j==4)
printf(" ctrl+s(save file)");
else if(j==16)
printf(" ctrl+k(Help)");
else if(j==26)
printf("ctrl+q(Quit)");
else
printf("*");}}
void typing(){
char *p= new char[2000];
step1 : int row=2,col=1;
while (ch!=19){
gotoxy(col,row);
step2 : if(col==79){
col=1;
row++;}
else if(row==24)
goto step1;
int a;
ch=getch();
if(ch==0)
ch=getch();
a=ch;
switch(a){
case 13:
row=++row;
col=1;
gotoxy(col,row);
ch='\n';
break;

case 8 :int i;
if(col==1) // case for backspace
{row--;col=78;}
else
{col--;
printf(" ");
i--;
}
continue;

case 9 : col=col+8; // case for tab function
if(col>79)
{row++;col=col-79;
}
continue;

case 72 : --row; //upper arrow key
continue;

case 77 : col++;
continue; //right arrow key

case 75 : col--;
continue; //left arrow key

case 80 : //down arrow key
++row;
continue;

case 14 : system("cls"); //to creat new file ctrl+n
printf("Enter File`s Path: ");
gets(s);
newfile(s);
starting();
break;

case 15 : system("cls"); //to open existing file ctrl+o
printf("Enter file`s path to be open :") ;
gets(xs);
starting();
openfile(xs);
continue;
case 83: col--;
continue;
case 17:
system("cls");
gotoxy(25,6);
printf("@^^$ No Pain No Gain @^^$");
getch();
exit(0);
case 11:
system("cls");
gotoxy(20,3);
printf("@@@@@@ HELP @@@@@@");
gotoxy(20,4);
printf("Keys Used in Project : ");
int am=10;
for(int i=0;i<46 ;i++ )
{
gotoxy(am,5);
printf("*");am++;}
am=6;
for(i=0;i<15;i++)
{gotoxy(10,am);
printf("#");
am++;}
am=10;
for( i=0;i<46 ;i++ )
{
gotoxy(am,21);
printf("*");
am++;}
am=6;
for(i=0;i<15;i++)
{gotoxy(56,am);
printf("#");
am++;}
gotoxy(13,6);
printf(" 1-To Open File Press ( ctrl + o ) ");
gotoxy(13,8);
printf(" 2-To create New File Press(ctrl+n) " );
gotoxy(13,10);
printf(" 3-MOve Arrow keys (up,down,right,left)") ;
gotoxy(13,12);
printf(" 4-Back Space ");
gotoxy(13,14);
printf(" 5-Save File(ctrl+s)");
gotoxy(13,16);
printf(" 6-Enter For new line ");
gotoxy(13,18);
printf(" 7-Enter ctrl+q(Quit)");

gotoxy(13,20);
printf("Press any key to Go back ") ;

getch();
system("cls");
starting();
continue;
}
cout<<ch;
p[i]=ch;
col++; i++;

p[i]='\0';
}
system("cls");
printf("enter path where you want to save the file: ");
gets(ys); int j=0;
ofstream f1(ys,ios::out);
while(p[j]!='\0')
{f1.write((char*)&p[j],sizeof(p[j]));
j++;}
f1.close();
delete [] p;
exit(0);}
void newfile(char *s){
ofstream file(s,ios::out);
file.close();
}
void openfile(char *xs){
char ch;
int col=3,row=2;
gotoxy(col,row);
ifstream file(xs,ios::in);
while( file.read((char*)&ch,sizeof(ch)))
cout<<ch;
file.close();}