I was making a simple winapi coding and suddenly encountered a wierd problem. This code:
HANDLE hConsOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFOEX infoex;
GetConsoleScreenBufferInfoEx(hConsOut, &infoex);
cout << "x: " << infoex.dwCursorPosition.X;
gives me output of "x: -13108". while this:
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(hConsole, &info);
cout << "x: " << info.dwCursorPosition.X;
gives me "x: 0", which is correct, expected answer.
I may be wrong, but isnt former an extended version of latter? And why, when having such similar uses, Extended version of buffer getting me (obviously) wrong data?
Both examples was taken from msdn and generates no compile-time errors.
First, i was interested in changing color of the console with
infoex.ColorTable[0] = RGB(255,0,0);
SetConsoleScreenBufferInfoEx(hConsOut, &infoex);
but when it failed, i decided to test if "infoex" variable got the right data. And it turned out that even retrieving cursor position with it was impossible.
Please tell me where am i wrong. Thanks in advance.