Hiding Console Cursor

Started by
6 comments, last by Ragadast 21 years, 10 months ago
Is there a way to hide the Consolo Cursor in C++? I'm trying to graphic some ASCII maps and try to use some basic AI, but the cursor appears every each place I want to cout something. Here's a part of the code:
        
HANDLE hOut;
char map[80][25];
map[2][2] = 'X';
COORD position;

hOut = GetStdHandle(STD_OUTPUT_HANDLE);

for(int i=0; i<80; i++)
{
    for(int e=0; e<25; e++)
    {
         position.X = i;
         position.Y = e;
       
         SetConsoloCursorPosition(hOut, position);
         cout << map[i][e];
    }
}
        
[edited by - Ragadast on June 6, 2002 10:10:16 PM]
Advertisement
Well, if you''re using Borland (Which I think you''re not) use:

_setcursortype( _NOCURSOR );


or _SOLIDCURSOR or _NORMALCURSOR

From the Borland Turbo C++ User''s Guide, Page 610. Chapter 20, Video Functions. (Hopefully, this can help you with the MS Stuff)
- Advice, eh? Well, besides working on your swing...you know, besides that...I'd have to think.
Give this a go:
ShowCursor(FALSE);
To turn it back on:
ShowCursor(TRUE);
-=bPhen=- , what a pity...
ShowCursor() shows or hides the mouse cursor, not the console cursor
Now I don''t exactly know how to do this; but if you''re trying to output ascii characters you could just enter graphics mode and reference the ASCII characters from memory from within the graphics mode. Andre La Mothe references this in his "Tricks of the 2D Games Programming Gurus" or "The Black Art of 3D Game Programming" books - I forget which one exactly.

Then you don''t need to worry about switching back and forth from different video modes and you have a character set all ready for your game. Of course, the characters are all Courier font, I think.
- Advice, eh? Well, besides working on your swing...you know, besides that...I'd have to think.
I''m doing it under VC++. I tried the ShowCursor() but i think that one is for the mouse cursor, or am i wrong? Well, anyway, it still shows the "_" cursor while it moves through each space in the screen. Thanks for the ones who already answered
You want the win32 API function:

SetConsoleCursorInfo()

MSDN library is your friend.

also check out the many other console functions - such as setting the console window title, size, using colors, and much more.
Jacob Marner, M.Sc.Console Programmer, Deadline Games
Hey, I just finised a game using just the console and bunch of ascii characters. Its a good way to learn stuff without getting boggled down with too much info.

Here is the link to all the console functions in MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/conchar_3vg3.asp


I forgot who gave the link but that was one awesome link. Its got all you need to do anything in the console. Good luck!
++postcount;

This topic is closed to new replies.

Advertisement