Okay, I've come up with this:
1 2 3 4 5 6 7 8 9 10
|
void SizeWindow(HWND& hMain, int iWidth, int iHeight)
{
RECT clRect, clWin;
clRect.right=iWidth;
clRect.bottom=iHeight;
GetWindowRect(hMain, &clWin);
AdjustWindowRectEx(&clRect, WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, FALSE, WS_EX_CLIENTEDGE);
MoveWindow(hMain, clWin.left, clWin.top, clRect.right, clRect.bottom, TRUE);
return;
}
|
Theoretically, with this function I could pass in two variables to use as width and height of the window's client area. It would then get the window's current size with GetWindowRect(), adjust the window size with AdjustWindowRectEx() based on the values passed in, then set the new size with MoveWindow(), correct?
Essentially, I was looking for some opinions on the pros and cons of this type of implementation. Is it a bad idea, and why? If not, what could be some good points of doing this?
Second, how about disabling the ability to change window size by pulling the window edges, and only setting a couple of different window sizes using this function that the user may choose from? Would people dislike not being able to control exact window size?
Edit: I maybe should have tried actually using that function beforehand, because it doesn't work as intended. However, the following fix does:
1 2 3 4 5 6 7 8 9
|
void SizeWindow(HWND& hMain, int iWidth, int iHeight)
{
RECT clRect={0, 0, iWidth, iHeight};
RECT clWin;
GetWindowRect(hMain, &clWin);
AdjustWindowRectEx(&clRect, WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, FALSE, WS_EX_CLIENTEDGE);
MoveWindow(hMain, clWin.left, clWin.top, clRect.right-clRect.left, clRect.bottom-clRect.top, TRUE);
return;
}
|
Questions remain the same though.