Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,133 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,811 people online right now. Registration is fast and FREE... Join Now!




how to get the current cursor position

 
Reply to this topicStart new topic

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

charitharanasingha
10 May, 2007 - 10:40 PM
Post #1

New D.I.C Head
*

Joined: 3 May, 2007
Posts: 3


My Contributions
CODE

#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;
}

User is offlineProfile CardPM
+Quote Post

gregoryH
RE: How To Get The Current Cursor Position
13 May, 2007 - 03:26 AM
Post #2

D.I.C Regular
Group Icon

Joined: 4 Oct, 2006
Posts: 417


Dream Kudos: 50
My Contributions
Hi

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

So, what was the question again?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:29PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month