| 1 |
#include <windows.h> |
| 2 |
|
| 3 |
#include <stdio.h> |
| 4 |
|
| 5 |
#include "TestUtil.cc" |
| 6 |
|
| 7 |
int main() { |
| 8 |
const HANDLE conout = openConout(); |
| 9 |
|
| 10 |
CONSOLE_SCREEN_BUFFER_INFO info = {}; |
| 11 |
BOOL ret = GetConsoleScreenBufferInfo(conout, &info); |
| 12 |
ASSERT(ret && "GetConsoleScreenBufferInfo failed"); |
| 13 |
|
| 14 |
trace("cursor=%d,%d", info.dwCursorPosition.X, info.dwCursorPosition.Y); |
| 15 |
printf("cursor=%d,%d\n", info.dwCursorPosition.X, info.dwCursorPosition.Y); |
| 16 |
|
| 17 |
trace("srWindow={L=%d,T=%d,R=%d,B=%d}", info.srWindow.Left, info.srWindow.Top, info.srWindow.Right, info.srWindow.Bottom); |
| 18 |
printf("srWindow={L=%d,T=%d,R=%d,B=%d}\n", info.srWindow.Left, info.srWindow.Top, info.srWindow.Right, info.srWindow.Bottom); |
| 19 |
|
| 20 |
trace("dwSize=%d,%d", info.dwSize.X, info.dwSize.Y); |
| 21 |
printf("dwSize=%d,%d\n", info.dwSize.X, info.dwSize.Y); |
| 22 |
|
| 23 |
const HWND hwnd = GetConsoleWindow(); |
| 24 |
if (hwnd != NULL) { |
| 25 |
RECT r = {}; |
| 26 |
if (GetWindowRect(hwnd, &r)) { |
| 27 |
const int w = r.right - r.left; |
| 28 |
const int h = r.bottom - r.top; |
| 29 |
trace("hwnd: pos=(%d,%d) size=(%d,%d)", r.left, r.top, w, h); |
| 30 |
printf("hwnd: pos=(%d,%d) size=(%d,%d)\n", r.left, r.top, w, h); |
| 31 |
} else { |
| 32 |
trace("GetWindowRect failed"); |
| 33 |
printf("GetWindowRect failed\n"); |
| 34 |
} |
| 35 |
} else { |
| 36 |
trace("GetConsoleWindow returned NULL"); |
| 37 |
printf("GetConsoleWindow returned NULL\n"); |
| 38 |
} |
| 39 |
|
| 40 |
return 0; |
| 41 |
} |