Solved

How to get console cursor position using VC++?

Posted on 2001-09-06
9
1,571 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

691 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