how to get the current cursor position

i want move cursor by arrow keys,to do that i want to get the current

Page 1 of 1

1 Replies - 3417 Views - Last Post: 13 May 2007 - 04:26 AM Rate Topic: -----

#1 charitharanasingha  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 03-May 07

how to get the current cursor position

Posted 10 May 2007 - 11:40 PM

#include<iostream.h>
#include <conio.h>
#include <stdio.h>

int design()
{
int i,j,x,y;
clrscr();
//up horizontal line
for(i=1;i<80;i++)
{
gotoxy(i,1);
cout<<"█";
}
//left vertical
for(i=1;i<=20;i++)
{
gotoxy(1,i);
cout<<"█"<<"\n";
}
//right vertical
/*for(i=1;i<=80;i++)
{
gotoxy(i,20);
cout<<"█";
} */
//down horizontal
for(i=1;i<=20;i++)
{
gotoxy(80,i);
cout<<"█"<<"\n";
}
 //horizontal lines
for(i=1;i<21;i++)
{
gotoxy(10,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(20,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(30,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(40,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(50,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(60,i);
cout<<"█"<<"\n";
}
for(i=1;i<21;i++)
{
gotoxy(70,i);
cout<<"█"<<"\n";
}
//finish the horizontal lines
//starting the vertical lines
for(i=1; i<80; i++)
{
gotoxy(i,5);
cout<<"█";
}
for(i=1; i<80; i++)
{
gotoxy(i,9);
cout<<"█";
}
for(i=1; i<80; i++)
{
gotoxy(i,13);
cout<<"█";
}
for(i=1; i<80; i++)
{
gotoxy(i,17);
cout<<"█";
}
for(i=1; i<81; i++)
{
gotoxy(i,21);
cout<<"█";
}
//starting room numbers
//1 first

gotoxy(6,3);
textcolor(20);
cprintf("1");
for(i=2,j=15; i<=8,j<85; i++,j=j+10)
{
gotoxy(j,3);
cout<<i;
}
gotoxy(6,7);
cout<<"9";
for(i=10,j=15; i<=18,j<85; i++,j=j+10)
{
gotoxy(j,7);
cout<<i;
}
gotoxy(6,11);
cout<<"17";
for(i=18,j=15; i<=18,j<85; i++,j=j+10)
{
gotoxy(j,11);
cout<<i;
}
gotoxy(6,15);
cout<<"25";
for(i=26,j=15; i<=18,j<85; i++,j=j+10)
{
gotoxy(j,15);
cout<<i;
}
gotoxy(6,19);
cout<<"33";
for(i=34,j=15; i<=18,j<85; i++,j=j+10)
{
gotoxy(j,19);
cout<<i;
}
//coloring of 1

getch();
return 0;
}
int color1()
{
int x=2;
int y=2;
while(y<5)
{
while(x<10)
{
gotoxy(x,y);
textcolor(75);
cprintf("█");
x=x+1;
}
y=y+1;
x=2;
}
getch();
return 0;
}
int menu()
{
int room;
gotoxy(25,25);
cout<<"Enter the room no to be reserved : ";
cin>>room;
if(room==1)
{
color1();
}
getch();
}
int main()
{
clrscr();
design();
menu();

return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: how to get the current cursor position

#2 gregoryH  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 60
  • View blog
  • Posts: 656
  • Joined: 04-October 06

Re: how to get the current cursor position

Posted 13 May 2007 - 04:26 AM

Hi

Nice code, could use a little indenting and some commenting...

So, what was the question again?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1