0

hi.
can anyone tell me how to disable blinkin cursor from my WIN32 console Application.

i have created a console app.. using vc++ but i see the cursor blinkin all the time which is not what i want.

please help

thanks in advance.

2
Contributors
4
Replies
7
Views
11 Years
Discussion Span
Last Post by sleevetrick
0

hey

thanks so much

but could you please give me an example..

please take a look at this code..

switch (prev_dir)
        {
        case 1:
        cout << "L";
        Sleep(2000);
        break;
        case 2:
        cout << "R";
        Sleep(2000);

        break;
        case 3:
        cout << "U";
        Sleep(2000);

        break;
        case 4:
        cout << "D";
        Sleep(2000);

        break;   
        }    
SetConsoleCursorPosition(hOutput, CursorPosition);
cout<<"W";
Sleep(2000);
SetConsoleCursorPosition(hOutput, CursorPosition);

suppose i wanted to print al of this on screen and everytime the key is L it moves to the left side and the cursor blinks with it..
please tell me as to how to disable the cursor or set the cursor background to black

cheers

Edited by pyTony: fixed formating

0

Below is a quick example -- you can get more console functions and a console class here

I compiled and tested this with Dev-C++ compiler on XP os.

#define _WIN32_WINNT 0x0500
#include <Windows.h>
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    
    CONSOLE_CURSOR_INFO info;
	HANDLE hOutput = GetStdHandle (STD_OUTPUT_HANDLE);

	// turn the cursor off
	info.bVisible = FALSE;
	info.dwSize = 1;
    if( SetConsoleCursorInfo(hOutput,&info) == 0 )
    {
       cout << endl << "SetConsoleCurInfo failed" << endl;
       DWORD dwError = GetLastError();
       char buf[255];
       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwError,
           0,buf,sizeof(buf),0);
       cout << buf << endl;
    }

    cout << "Press <Enter> when ready";
    cin.ignore();

	return 0;
}
0

Below is a quick example -- you can get more console functions and a console class here

I compiled and tested this with Dev-C++ compiler on XP os.

#define _WIN32_WINNT 0x0500
#include <Windows.h>
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    
    CONSOLE_CURSOR_INFO info;
	HANDLE hOutput = GetStdHandle (STD_OUTPUT_HANDLE);

	// turn the cursor off
	info.bVisible = FALSE;
	info.dwSize = 1;
    if( SetConsoleCursorInfo(hOutput,&info) == 0 )
    {
       cout << endl << "SetConsoleCurInfo failed" << endl;
       DWORD dwError = GetLastError();
       char buf[255];
       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwError,
           0,buf,sizeof(buf),0);
       cout << buf << endl;
    }

    cout << "Press <Enter> when ready";
    cin.ignore();

	return 0;
}

thanks a lot!

i appreciate it!

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.