Solved

How to get console cursor position using VC++?

Posted on 2001-09-06
9
1,509 Views
Last Modified: 2008-02-01
How to get console cursor position using VC++?
and how to set the cursor info?

Thanks.
0
Comment
Question by:Knight_G
  • 5
  • 4
9 Comments
 
LVL 2

Expert Comment

by:bkdc
ID: 6460113
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
 

Author Comment

by:Knight_G
ID: 6460194
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
 
LVL 2

Expert Comment

by:bkdc
ID: 6460225
0
 

Author Comment

by:Knight_G
ID: 6460242
#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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
bkdc earned 50 total points
ID: 6460256
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
 

Author Comment

by:Knight_G
ID: 6460563
There is no error now, but there is no effect when i change
the value of dwSize and bVisible.
0
 
LVL 2

Expert Comment

by:bkdc
ID: 6460733
does the SetConsoleCursorInfo function fail? Check to see what it returns (true/false)
0
 

Author Comment

by:Knight_G
ID: 6460847
Yeah, it working now!
You help me learn so much

A million thanks on ur help!!!!
0
 
LVL 2

Expert Comment

by:bkdc
ID: 6461352
live long and prosper :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now