Link to home
Start Free TrialLog in
Avatar of NOPz
NOPz

asked on

Windows Console Programming Problem

I am trying to code a HideCursor() function.Iread the MSDN i thought
I knew what to do ..but it turns out my function does not work.

This is how i implemented it.

void System::HideCursor(void)
{
     HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
     CONSOLE_CURSOR_INFO   CursorInfo;
     char buffer[10]={0};
     CursorInfo.bVisible=false;
     CursorInfo.dwSize=0;
     SetConsoleCursorInfo(Console,&CursorInfo); // HERE OCCURS THE ERROR, THE FUNCTION FAILS
     
}

But it does absolutely nothing.Do not waste time dubugging.
I traced the error and it seems to be System Error 87 : The Parameter is Incorect.

Now why is this happening.I even tried the more radical solution
...that is using a CONSOLE_CURSOR_INFO *CursorInfo. The function failed in that case too.

Please help me find a solution.Thank you!

Somehow, the printf() and cout<< functions don't appear to work in this environment.anybody have an
idea on this?
Avatar of owenw
owenw

According to the MSDN documentation for CONSOLE_CURSOR_INFO, the dwSize member must be between 1 and 100 (apparently inclusive). Try setting it to 1 instead of 0. :)
ASKER CERTIFIED SOLUTION
Avatar of DAnderson
DAnderson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried it after fixing the bad param and sure the cursor did disappear.