Reputation: 173
I am drawing a rectangle (in OpenGL) and the corner are based on the cursor position. I modify the pixel position to a float position, but i need the width and height (Which is save somewhere).
So i did some test and on a 1024x512 window, the upper left corner is indeed (0,0) but the bottom corner is (1007,473) or something near.
Now it works ok, but if the window get resize, then it obviously won't work anymore, so here is my question:
How can i get the border size? That way i think i can subtract it from the window size and get the right position for my cursor to draw the rectangle.
Upvotes: 0
Views: 4612
Reputation: 13532
On windows you can use GetWindowRect
and GetClientRect
RECT windowRect;
GetWindowRect(hwnd, &windowRect);
RECT clientRect;
GetClientRect(hwnd, &clientRect);
int borderWidth = ((windowRect.right - windowRect.left) - (clientRect.right -clientRect.left))/2;
Though GetClientRect
should give you the inner width of the window and that should be enough for you.
int innerWidth = clientRect.right - clientRect.left;
Upvotes: 3