Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PROBLEMS with getting console info

Status
Not open for further replies.

shadowsilver

Programmer
Nov 26, 2002
10
US
Can anybody help me? I'm trying to use the GetConsoleScreenBufferInfo function to get the location of the cursor on the screen at any time, but I'm having troubles. I've studied MSDN, and thought I'd figured it out, but it didn't work. I've looked all over for example source code for that function, but couldn't find any that did the same thing I was trying to do. By the way, I'm using the Dev-C++ 4.9.6.0 compiler.

Here's the source code:
Code:
PCONSOLE_SCREEN_BUFFER_INFO BufInfo;
HANDLE MyHand = GetStdHandle(STD_OUTPUT_HANDLE); 
GetConsoleScreenBufferInfo(MyHand, BufInfo);
COORD MyCoord;
MyCoord = BufInfo.dwCursorPosition;
if (MyCoord == (0,1))
  { etc;}

The error i'm getting is:
"In function 'int main()' : request for member 'dwCursorPosition' in 'BufInfo', which is of non-aggregate type _CONSOLE_SCREEN_BUFFER_INFO"
I don't even know what non-aggregate type means!

Any help or recommendations would be appreciated very much.
Thanks.
 
I don't know MFC, but "non-aggregate type" just means something that's not a class or struct.

That means _CONSOLE_SCREEN_BUFFER_INFO is probably a typedef for something like an int, which can't be used with the dot operator, and most certainly doesn't have a member called dwCursorPosition (or any members at all, for that matter).
 
But it's all at MSDN, it shows the contents of that struct and everything! I think I can do it another way, though.
Thanks anyways!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top