Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

suppressing cursor in console app ? 1

Status
Not open for further replies.

rezzij

Instructor
Mar 30, 2004
48
US
Is there a way to disable the blinking cursor in a console application? Tried some 3rd party apps with no luck...
thanks
 
See example and make your own function:
Code:
int main(int argc, char* argv[])
{
	HANDLE	h;
	CONSOLE_CURSOR_INFO cur;
	memset(&cur,0,sizeof cur);

	h = GetStdHandle(STD_OUTPUT_HANDLE);
	if (h == INVALID_HANDLE_VALUE)
	{
          cout << "*** Can\'t obtain handle..." << endl;
		system("pause");
		exit(1);
	}
	if (!GetConsoleCursorInfo(h,&cur))
	{
           cout << "*** Can't get cursor info..." << endl;
		system("pause");
		exit(1);
	}

	cout << "Let\'s try cursor off..." << endl;
	system("pause");
	
	cur.bVisible = 0;
	SetConsoleCursorInfo(h,&cur);
	cout << "Well..." << endl;
	system("pause");

	cur.bVisible = 1;
	SetConsoleCursorInfo(h,&cur);
	cout << "Now on..." << endl;
	system("pause");
	return 0;
}
All names are in <windows.h> (strictly speaking, from <winuser.h>)...
 
Thanks - worked perfectly,, but didn't solve my problem ...
I was displaying some simple graphics in succession, and it flickered pretty badly - I thought due to the blinking cursor in the middle .... shutting it off didn't help ...
but I do appreciate the info for the future!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top