[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

How to get console cursor position using VC++?

How to get console cursor position using VC++?
and how to set the cursor info?

Thanks.
0
Knight_G
Asked:
Knight_G
  • 5
  • 4
1 Solution
 
bkdcCommented:
To determine the current cursor position and attributes call GetConsoleScreenBufferInfo(..).
 SetConsoleTextAttribute changes the text color.
 You might try SetConsoleMode / GetConsoleMode too.
 SetConsoleCursorPosition - you figure it ....
0
 
Knight_GAuthor Commented:
Can you pls write the exact usage of
GetConsoleScreenBufferInfo,
SetConsoleMode
SetConsoleCursorInfo

I had refered to the MSDN library, but i don't know how to call them.
Thanks.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Knight_GAuthor Commented:
#include <windows.h>

void main()
{

     HANDLE StdOut = GetStdHandle(STD_OUTPUT_HANDLE);

     CONSOLE_CURSOR_INFO cursor = {50, true};
     SetConsoleCursorInfo(StdOut, cursor);


}


The following errors are found:
C2664: 'SetConsoleCursorInfo' : cannot convert parameter 2 from 'struct _CONSOLE_CURSOR_INFO' to 'const struct _CONSOLE_CURSOR_INFO *'


Pls help.
0
 
bkdcCommented:
GEee, I hink i've already answered your question, but hey, what the hell...

try this: SetConsoleCursorInfo(StdOut, &cursor);
sorry, no compiler 50m around me so....you're on your own

anyway, it should work.

Really,really desperate solution:
 CONSOLE_CURSOR_INFO *stuff;
 stuff->....
 SetConsoleCursorInfo(StdOut, stuff);








0
 
Knight_GAuthor Commented:
There is no error now, but there is no effect when i change
the value of dwSize and bVisible.
0
 
bkdcCommented:
does the SetConsoleCursorInfo function fail? Check to see what it returns (true/false)
0
 
Knight_GAuthor Commented:
Yeah, it working now!
You help me learn so much

A million thanks on ur help!!!!
0
 
bkdcCommented:
live long and prosper :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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