Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change
invoke MoveWindow, hWin, rct.left, rct.top, eax, edx, TRUE
It should be slightly off the top and left of the screen edges. .if uMsg == WM_INITDIALOG
;; fill RECT with desired client area dimensions
mov rct.left, 0
mov rct.top, 0
mov rct.right, cwidth ; 240
mov rct.bottom, cheight ; 240
; rct has your desired size
invoke AdjustWindowRect, addr rct, WS_VISIBLE or WS_OVERLAPPEDWINDOW, 0
invoke SystemParametersInfoA, SPI_GETWORKAREA, 0, addr rctD, 0
;window_width = (rct.right - rct.left)
;window_heighth = (rct.bottom - rct.top)
mov ecx,rct.right
mov edx,rct.bottom
sub ecx,rct.left ;window width
sub edx,rct.top ;window height
;desktop_width = rctD.right
;desktop_height = rctD.bottom
mov esi,rctD.right
mov edi,rctD.bottom
;desktop left/top should always be 0
;sub esi,rctD.left ;desktop width
;sub edi,rctD.top ;desktop height
;window_x = desktop_width - window_width / 2
;window_y = desktop_height - window_height / 2
sub esi,ecx
sub edi,edx
shr esi,1 ;window x
shr edi,1 ;window y
invoke MoveWindow,hWin,esi,edi,ecx,edx,TRUE
;; fill RECT with desired client area dimensions
mov rct.left, 0
mov rct.top, 0
mov rct.right, cwidth ; 240
mov rct.bottom, cheight ; 240
; rct has your desired size
invoke AdjustWindowRect, addr rct, WS_VISIBLE or WS_OVERLAPPEDWINDOW, 0
lea ecx, rct
mov eax, [ecx].RECT.right
mov edx, [ecx].RECT.bottom
sub eax, [ecx].RECT.left ; new window width
sub edx, [ecx].RECT.top ; new window height
invoke MoveWindow, hWin, 0, 0, eax, edx, TRUE
invoke GetWindowRect, hWin, addr rct
fn lstrcpy, addr buffer, "rct.left = "
invoke lstrcat, addr buffer, str$(rct.left)
invoke lstrcat, addr buffer, addr crlf
fn lstrcat, addr buffer, "rct.top = "
invoke lstrcat, addr buffer, str$(rct.top)
invoke lstrcat, addr buffer, addr crlf
fn lstrcat, addr buffer, "rct.right = "
invoke lstrcat, addr buffer, str$(rct.right)
invoke lstrcat, addr buffer, addr crlf
fn lstrcat, addr buffer, "rct.bottom = "
invoke lstrcat, addr buffer, str$(rct.bottom)
invoke MessageBox, 0, addr buffer, 0, 0
After moving the window I called GetWindowRect to obtain the window RECT which is where the window is supposed to be. But when the window is shown, x is 0+7 (rct.left). I do not know how to reconcile this apparent discrepancy.Quote from: sinsi on Today at 02:18:19 AMActually, the adjusted rectangle is -8, -31, 248, 248.I did not look at the RECT structure values after the adjustment, just the changes in dialog box Window location and size after the AdjustWindowRect call.
This is because your client x,y is 0,0 so converting it to a window will take into account things like the border and title bar.
You still have to have code to centre it though.
.if uMsg == WM_INITDIALOG
;; fill RECT with desired client area dimensions
mov rct.left, 0
mov rct.top, 0
mov rct.right, cwidth ; 240
mov rct.bottom, cheight ; 240
; rct has your desired size
invoke AdjustWindowRect, addr rct, WS_VISIBLE or WS_OVERLAPPEDWINDOW, 0
lea ecx, rct
mov eax, [ecx].RECT.right
mov edx, [ecx].RECT.bottom
sub eax, [ecx].RECT.left ; new window width in eax
sub edx, [ecx].RECT.top ; new window height in edx
invoke MoveWindow, hWin, 0, 0, eax, edx, TRUE
Prior to centering the window, I tested this code first.