Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

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?
0
NOPz
Asked:
NOPz
  • 2
1 Solution
 
owenwCommented:
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. :)
0
 
DAndersonCommented:
Easy: read again

here is the quote:

Remarks
When a screen buffer's cursor is visible, its appearance can vary, ranging from completely filling a character cell to showing up as a horizontal line at the bottom of the cell. The dwSize member of the CONSOLE_CURSOR_INFO structure specifies the percentage of a character cell that is filled by the cursor. If this member is less than 1 or greater than 100, SetConsoleCursorInfo fails.

0
 
DAndersonCommented:
I tried it after fixing the bad param and sure the cursor did disappear.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now