#### Archived

This topic is now archived and is closed to further replies.

# How to control a DOS cursor?!?

This topic is 5596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Okay, lets say I use the simple C++ cout to put this on a Dos Console: Option 1 Option 2 Option 3 What I am trying to do is make a text menu for a text game. However, I can''t figure out how to tell the program to set the cursor to a certain position! Like for option 3 the position would be x = 9 and y = 3. I want to paste a -> where those locations are. How can I do this? I use MSVC.NET gotoxy() doesn''t work (MSVC.NET doesn''t want to seem to compile the header file, conio.h which is needed for that) Thanks. Alex

##### Share on other sites
Can''t find anything about "gotoxy" on msdn site.
Since i''m not anybody i can''t really reply to
your question but i may suggest you to use an older
compiler like BC++ or WATCOM.

Hope it helps

##### Share on other sites
gotoxy() is not a standard function (I believe only Borland and CodeWarrior support it). If you are programming for Windows (which you seem to be) you will need to use the Windows Character-Mode Application functions (here) - specifically the SetConsoleCursorPosition function.

Qui fut tout, et qui ne fut rien

##### Share on other sites
quote:
gotoxy() is not a standard function (I believe only Borland and CodeWarrior support it). If you are programming for Windows (which you seem to be) you will need to use the Windows Character-Mode Application functions (<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/character_mode_applications.asp">here</a> - specifically the SetConsoleCursorPosition function.

<hr>
Qui fut tout, et qui ne fut rien

na correction, you can open up the conio.h and cut and paste the file into a seperate header. You only need to include windows.h becasue the gotoxy() uses pure windows api functions for placing the cursor.

Although theres has been some problems with using cout, using printf instead to print out to the screen after you''ve set the gotoxy(X,Y) of your screen will usually solve the problem.

void gotoxy(int x, int y){	COORD point;	if((x < 0 || x > screensize.x) || (y < 0 || y > screensize.y))		return;	point.X = x; point.Y = y;	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), point);}

I use the most of the conio.h code from the devc++ compiler, it''s been great with the console interface for my programs. I''ve cross compiled in both borland c++ 5.1 free, c++ builder 6, vc++ 6, and of course devc++.

Hope this helps, theres also more functions for clearing the screen, clearing till the end of the current line.

##### Share on other sites
Thank you so much! Why don''t you register here? You seem to know what your doing; and would probably be a very nice contributor to the GameDev forums!

Well again, thank you so much!

Alex

##### Share on other sites
quote:
Original post by PointSoft
Thank you so much! Why don't you register here? You seem to know what your doing; and would probably be a very nice contributor to the GameDev forums!

Well again, thank you so much!

Alex

Thanks, I am registered.. just the forums seem to be mucked up.. and double posted me.. one with anonymous...

BTW: when is the search going to get fixed..

[edited by - tonic151 on January 27, 2003 1:41:22 PM]

• 40
• 15
• 10
• 23
• 19