Skip to content

Commit db6ac04

Browse files
committed
[U32] SetWindowPos
1 parent ec5b389 commit db6ac04

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

dlls/user32/extras.hexa

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3665,7 +3665,47 @@ fun setWindowPos(
36653665
uFlags UInt32 // Window positioning flags
36663666
) Bool32 // Determine whether a window is a child of another window
36673667
{
3668-
tofitaDebugLog("setWindowPos called".utf16())
3668+
tofitaDebugLog("SetWindowPos called with hWnd %8 hWndInsertAfter %8".utf16(), hWnd as! UInt64, hWndInsertAfter as! UInt64)
3669+
tofitaDebugLog("> x %d y %d".utf16(), x as! UInt64, y as! UInt64)
3670+
tofitaDebugLog("> cx %d cy %d".utf16(), cx as! UInt64, cy as! UInt64)
3671+
tofitaDebugLog("> uFlags %u".utf16(), uFlags as! UInt64)
3672+
// sendMessageW(hWnd, Message.WM_MOVE, null, null)
3673+
// NOTE set default values
3674+
let info = MINMAXINFO()
3675+
// Send both as LParam and WParam for now
3676+
sendMessageW(hWnd, Message.WM_GET_MIN_MAX_INFO, info as! WParam, info as! LParam)
3677+
3678+
// if (uFlags & SWP_NOMOVE) == 0 {
3679+
// info.ptReserved.x = x
3680+
// info.ptReserved.y = y
3681+
// }
3682+
3683+
let window = handleToWindow(hWnd)
3684+
if window == null {
3685+
tofitaDebugLog("> window == null".utf16())
3686+
return null
3687+
}
3688+
3689+
if info.ptMinTrackSize.ref.x > window.width or info.ptMinTrackSize.ref.y > window.height {
3690+
window.width = info.ptMinTrackSize.ref.x
3691+
window.height = info.ptMinTrackSize.ref.y
3692+
tofitaDebugLog("> new size %d x %d".utf16(), window.width as! UInt64, window.height as! UInt64)
3693+
3694+
// NOTE check `windowId != 0`
3695+
let payload = ShowWindowPayload()
3696+
payload.windowId = window.windowId
3697+
payload.nCmdShow = CmdShow.SW_UNCHANGED
3698+
payload.x = -1
3699+
payload.y = -1
3700+
payload.width = window.width
3701+
payload.height = window.height
3702+
tofitaShowWindow(payload)
3703+
3704+
// NOTE wParam set to null (indicating a size change without specific flags like SIZE_MAXIMIZED)
3705+
let lParam = LParam.makeULong(window.width as! UInt16, window.height as! UInt16) as! LParam
3706+
sendMessageW(hWnd, Message.WM_SIZE, null, lParam)
3707+
}
3708+
36693709
return Bool32.True
36703710
}
36713711

0 commit comments

Comments
 (0)