Hi. I wrote two functions that adjust the position of the game window, but each time these functions run, the size of the game objects either increases or decreases. It’s probably a resolution-related issue. I want the size of the game objects to remain the same. How can I solve this problem?
Code:
public void IncreaseWindowHeightByOne()
{
int handle = GetActiveWindow();
RECT windowRect;
if (GetWindowRect(handle, out windowRect))
{
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
height += 1;
SetWindowPos(handle, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
}
}
public void DecreaseWindowHeightByOne()
{
int handle = GetActiveWindow();
RECT windowRect;
if (GetWindowRect(handle, out windowRect))
{
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
height -= 1;
SetWindowPos(handle, HWND_TOP, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
}
}