Hi
I found another good post here
https://devblogs.microsoft.com/oldnewthing/20030911-00/?p=42553Basically AdjustWindowRectEx doesn't know anything about the menu you're using, so it fails when the menu bar is folded.
The code shown corrects this behavior.

Here is the assembler translation.

I replaced the old code in ObjMem.lib with this one:
align ALIGN_CODE
SetClientSize proc uses xbx hWnd:HWND, dCx:DWORD, dCy:DWORD
local hMenu:HMENU, rcWindow:RECT, rcTemp:RECT
mov hMenu, $invoke(GetMenu, hWnd)
mov rcWindow.left, 0
mov rcWindow.top, 0
m2m rcWindow.right, dCx, eax
m2m rcWindow.bottom, dCy, eax
;First convert the client rectangle to a window rectangle
;the menu-wrap-agnostic way.
invoke GetWindowLongPtr, hWnd, GWL_STYLE
mov ebx, eax
invoke GetWindowLongPtr, hWnd, GWL_EXSTYLE
lea xcx, rcWindow
mov edx, ebx
xor ebx, ebx
.if hMenu != 0
inc ebx
.endif
invoke AdjustWindowRectEx, xcx, edx, ebx, eax
;If there is a menu, then check how much wrapping occurs when we set a
;window to the width specified by AdjustWindowRect and an infinite amount
;of height. An infinite height allows us to see every single menu wrap.
.if ebx != 0
s2s rcTemp, rcWindow, xax, xcx, xdx, xmm0, xmm1, xmm2, xmm3
mov rcTemp.bottom, 7FFFh ;"Infinite" height
invoke SendMessage, hWnd, WM_NCCALCSIZE, FALSE, addr rcTemp
;Adjust our previous calculation to compensate for menu wrapping.
mov eax, rcTemp.top
add rcWindow.bottom, eax
mov eax, rcWindow.right
sub eax, rcWindow.left
mov ebx, rcWindow.bottom
sub ebx, rcWindow.top
invoke SetWindowPos, hWnd, NULL, 0, 0, eax, ebx, SWP_NOMOVE or SWP_NOZORDER
.endif
ret
SetClientSize endp
Biterider