1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

#138 fix bMenu bool in AdjustWindowRect calls

(cherry picked from commit aee8747898f7b41f92e93ae8dd80c8ac5b38291e)
This commit is contained in:
FunkyFr3sh 2022-02-04 04:50:23 +01:00
parent 8409769b73
commit f013a76c7e
3 changed files with 23 additions and 10 deletions

View File

@ -674,7 +674,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
RECT dst = { x, y, g_ddraw->render.width + x, g_ddraw->render.height + y }; RECT dst = { x, y, g_ddraw->render.width + x, g_ddraw->render.height + y };
AdjustWindowRect(&dst, GetWindowLong(g_ddraw->hwnd, GWL_STYLE), FALSE); AdjustWindowRect(&dst, GetWindowLong(g_ddraw->hwnd, GWL_STYLE), GetMenu(g_ddraw->hwnd) != NULL);
real_SetWindowPos(g_ddraw->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); real_SetWindowPos(g_ddraw->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
real_MoveWindow(g_ddraw->hwnd, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), TRUE); real_MoveWindow(g_ddraw->hwnd, dst.left, dst.top, (dst.right - dst.left), (dst.bottom - dst.top), TRUE);

View File

@ -199,6 +199,7 @@ void util_toggle_maximize()
LONG style = GetWindowLong(g_ddraw->hwnd, GWL_STYLE); LONG style = GetWindowLong(g_ddraw->hwnd, GWL_STYLE);
LONG exstyle = GetWindowLong(g_ddraw->hwnd, GWL_EXSTYLE); LONG exstyle = GetWindowLong(g_ddraw->hwnd, GWL_EXSTYLE);
BOOL got_menu = GetMenu(g_ddraw->hwnd) != NULL;
if (real_GetClientRect(g_ddraw->hwnd, &client_rc) && SystemParametersInfo(SPI_GETWORKAREA, 0, &dst_rc, 0)) if (real_GetClientRect(g_ddraw->hwnd, &client_rc) && SystemParametersInfo(SPI_GETWORKAREA, 0, &dst_rc, 0))
{ {
@ -214,7 +215,7 @@ void util_toggle_maximize()
dst_rc.right = g_ddraw->width; dst_rc.right = g_ddraw->width;
dst_rc.bottom = g_ddraw->height; dst_rc.bottom = g_ddraw->height;
AdjustWindowRectEx(&dst_rc, style, FALSE, exstyle); AdjustWindowRectEx(&dst_rc, style, got_menu, exstyle);
} }
else if (g_ddraw->boxing) else if (g_ddraw->boxing)
{ {
@ -233,11 +234,11 @@ void util_toggle_maximize()
} }
} }
AdjustWindowRectEx(&dst_rc, style, FALSE, exstyle); AdjustWindowRectEx(&dst_rc, style, got_menu, exstyle);
} }
else if (g_ddraw->maintas) else if (g_ddraw->maintas)
{ {
util_unadjust_window_rect(&dst_rc, style, FALSE, exstyle); util_unadjust_window_rect(&dst_rc, style, got_menu, exstyle);
int w = dst_rc.right - dst_rc.left; int w = dst_rc.right - dst_rc.left;
int h = dst_rc.bottom - dst_rc.top; int h = dst_rc.bottom - dst_rc.top;
@ -253,7 +254,7 @@ void util_toggle_maximize()
dst_rc.bottom = h; dst_rc.bottom = h;
} }
AdjustWindowRectEx(&dst_rc, style, FALSE, exstyle); AdjustWindowRectEx(&dst_rc, style, got_menu, exstyle);
} }
RECT pos_rc; RECT pos_rc;
@ -262,8 +263,8 @@ void util_toggle_maximize()
pos_rc.right = (dst_rc.right - dst_rc.left); pos_rc.right = (dst_rc.right - dst_rc.left);
pos_rc.bottom = (dst_rc.bottom - dst_rc.top); pos_rc.bottom = (dst_rc.bottom - dst_rc.top);
util_unadjust_window_rect(&pos_rc, style, FALSE, exstyle); util_unadjust_window_rect(&pos_rc, style, got_menu, exstyle);
util_unadjust_window_rect(&dst_rc, style, FALSE, exstyle); util_unadjust_window_rect(&dst_rc, style, got_menu, exstyle);
util_set_window_rect( util_set_window_rect(
pos_rc.left, pos_rc.left,

View File

@ -252,7 +252,11 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
/* maintain aspect ratio */ /* maintain aspect ratio */
if (g_ddraw->maintas && if (g_ddraw->maintas &&
CopyRect(&clientrc, windowrc) && CopyRect(&clientrc, windowrc) &&
util_unadjust_window_rect(&clientrc, GetWindowLong(hWnd, GWL_STYLE), FALSE, GetWindowLong(hWnd, GWL_EXSTYLE)) && util_unadjust_window_rect(
&clientrc,
GetWindowLong(hWnd, GWL_STYLE),
GetMenu(hWnd) != NULL,
GetWindowLong(hWnd, GWL_EXSTYLE)) &&
SetRect(&clientrc, 0, 0, clientrc.right - clientrc.left, clientrc.bottom - clientrc.top)) SetRect(&clientrc, 0, 0, clientrc.right - clientrc.left, clientrc.bottom - clientrc.top))
{ {
float scaleH = (float)g_ddraw->height / g_ddraw->width; float scaleH = (float)g_ddraw->height / g_ddraw->width;
@ -285,7 +289,11 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
/* enforce minimum window size */ /* enforce minimum window size */
if (CopyRect(&clientrc, windowrc) && if (CopyRect(&clientrc, windowrc) &&
util_unadjust_window_rect(&clientrc, GetWindowLong(hWnd, GWL_STYLE), FALSE, GetWindowLong(hWnd, GWL_EXSTYLE)) && util_unadjust_window_rect(
&clientrc,
GetWindowLong(hWnd, GWL_STYLE),
GetMenu(hWnd) != NULL,
GetWindowLong(hWnd, GWL_EXSTYLE)) &&
SetRect(&clientrc, 0, 0, clientrc.right - clientrc.left, clientrc.bottom - clientrc.top)) SetRect(&clientrc, 0, 0, clientrc.right - clientrc.left, clientrc.bottom - clientrc.top))
{ {
if (clientrc.right < g_ddraw->width) if (clientrc.right < g_ddraw->width)
@ -337,7 +345,11 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
/* save new window position */ /* save new window position */
if (CopyRect(&clientrc, windowrc) && if (CopyRect(&clientrc, windowrc) &&
util_unadjust_window_rect(&clientrc, GetWindowLong(hWnd, GWL_STYLE), FALSE, GetWindowLong(hWnd, GWL_EXSTYLE))) util_unadjust_window_rect(
&clientrc,
GetWindowLong(hWnd, GWL_STYLE),
GetMenu(hWnd) != NULL,
GetWindowLong(hWnd, GWL_EXSTYLE)))
{ {
g_config.window_rect.left = clientrc.left; g_config.window_rect.left = clientrc.left;
g_config.window_rect.top = clientrc.top; g_config.window_rect.top = clientrc.top;