Annoying blinking cursor

Hello people,
is there a way to stop the cursor from blinking in the output window(or showing up at all)?

Example:
cout<<"Hello world";

Output:
Hello world_

//where last character keeps blinking

I use DevC++ in Windows 7. Thanks in advance.
closed account (o3hC5Di1)
Hi there,

You may want to have a look at: http://msdn.microsoft.com/en-us/library/system.console.cursorvisible.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1

Let us know if you require any further help.

All the best,
NwN
@kienme

Here's the function I use.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Cursor Control.cpp : main project file.

#include <iostream>
#include <windows.h>

void setcursor(bool visible, DWORD size);

int main()
{
	std::cout << "Cursor on for 10 seconds..." << std::endl;
   std::cout << "Hello World ";
	for (int x=0;x<10;x++)
   	    Sleep(1000);
	
	std::cout << std::endl;
	   
	std::cout << "Cursor OFF for 10 seconds..." << std::endl;
     std::cout << "Hello World ";
	
	 setcursor(0,0);
	for (int x=0;x<10;x++)
   	   Sleep(1000);

	std::cout << std::endl;
		std::cout << "Cursor back on..." << std::endl;
		setcursor(1,20);
	 std::cout << "Hello World " << std::endl;
	
    return 0;
}

void setcursor(bool visible, DWORD size)  // set bool visible = 0 - invisible, bool visible = 1 - visible
{
	HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
	if(size == 0)
	{
		size = 20;	// default cursor size Changing to numbers from 1 to 20, decreases cursor width
	}
	CONSOLE_CURSOR_INFO lpCursor;	
	lpCursor.bVisible = visible;
	lpCursor.dwSize = size;
	SetConsoleCursorInfo(console,&lpCursor);
}
Aah yes! That was helpful, thankyou, NwN and whitenite1.
Topic archived. No new replies allowed.