Solved

How to get console cursor position using VC++?

Posted on 2001-09-06
9
1,497 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:Knight_G
Comment Utility
#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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Accepted Solution

by:
bkdc earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
does the SetConsoleCursorInfo function fail? Check to see what it returns (true/false)
0
 

Author Comment

by:Knight_G
Comment Utility
Yeah, it working now!
You help me learn so much

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

Expert Comment

by:bkdc
Comment Utility
live long and prosper :)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

744 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

10 Experts available now in Live!

Get 1:1 Help Now