Public Group

Removing Console Input Underscore? (solved)

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

Recommended Posts

I am working on a console-based engine for *serious* game development, however I have run into one problem that I can't solve. A picture would be the best to show the problem: [image removed] You can see the annoying underscore that is there as if normal console input was expected. I just want to completely get rid of it. The thing is, if there is no character attributes set on that particular character, the cursor is invisible. I looked over MSDN's console functions but nothing there suits my needs, and I thought that perhaps someone who has done this in the past has a workaround. If there's no way to fix it I just won't use that character. I'm using Visual Studio 2008 with C++, if that is relevant. [Edited by - Kuraitou on March 18, 2009 9:19:33 PM]

Share on other sites
I am unsure of how to achieve the behavior you want, however...

you may want to consider using a different console library for a more robust set of console features. It might prove to be more useful for your needs in the long run.

Share on other sites
The problem with that is that I'm developing my own engine, not using someone else's. I just want a way to remove the underscore that appears when you type.

Share on other sites
I see SetConsoleCursorInfo and CONSOLE_CURSOR_INFO. I would try something like this

CONSOLE_CURSOR_INFO cursor_info;GetConsoleCursorInfo(hConsoleHandle, &cursor_info);cursor_info.bVisible = FALSE;SetConsoleCursorInfo(hConsoleHandle, &cursor_info);

But that is just a guess.

Share on other sites
I think the function you need is SetConsoleCursorInfo
take a look at http://msdn.microsoft.com/en-us/library/ms686019(VS.85).aspx
you can then just set the cursor as invisible.

Share on other sites
Ah, I must have overlooked that. I had been doing this before, but it wasn't working:

	CONSOLE_CURSOR_INFO *pCCI = new CONSOLE_CURSOR_INFO();	pCCI->bVisible = false;	pCCI->dwSize = 0;	SetConsoleCursorInfo(m_wHnd, pCCI);	delete pCCI;

(Now after looking at it, I suspect the delete statement, another part of my stupidity. Also this is a very stupid place to use pointers.) Thanks to both of you and ++ratings.

Share on other sites
Quote:
 Original post by KuraitouAh, I must have overlooked that. I had been doing this before, but it wasn't working:*** Source Snippet Removed ***(Now after looking at it, I suspect the delete statement, another part of my stupidity. Also this is a very stupid place to use pointers.) Thanks to both of you and ++ratings.

Then don't use pointers. You can do this just as easily:
	CONSOLE_CURSOR_INFO CCI;	CCI.bVisible = false;	CCI.dwSize = 0;	SetConsoleCursorInfo(m_wHnd, &CCI);
(not tested)
Remember, just because a function takes a pointer doesn't necessarily mean manual memory allocation/deallocation.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
18
5. 5

• 9
• 33
• 13
• 13
• 10
• Forum Statistics

• Total Topics
632582
• Total Posts
3007216

×