Hello
I want set the Clientsize not the Windowsize, so I wrote this procedure.
Isn't there another way?
Best Regards, Thomas
SetClientRect proc hWnd, X, Y :dword
local Rect1 :RECT, Rect2 :RECT
invoke GetWindowRect, hWnd, addr Rect1
invoke GetClientRect, hWnd, addr Rect2
mov eax, Rect1.right
sub eax, Rect1.left
sub eax, Rect2.right
add eax, X
mov Rect1.right, eax
mov eax, Rect1.bottom
sub eax, Rect1.top
sub eax, Rect2.bottom
add eax, Y
mov Rect1.bottom, eax
invoke SetWindowPos, hWnd, HWND_NOTOPMOST, 0, 0, Rect1.right, Rect1.bottom, SWP_NOMOVE
ret
SetClientRect endp
I use this:
;--------------------------------------------------
; This procedure sizes the specified window so the
; client area is the specified width and height.
;--------------------------------------------------
SetClientSize proc uses ebx hwnd:HWND, pixelWidth:DWORD, pixelHeight:DWORD
LOCAL rcc:RECT, rcw:RECT
invoke GetClientRect, hwnd, ADDR rcc
invoke GetWindowRect, hwnd, ADDR rcw
mov ecx, rcw.right
sub ecx, rcw.left ; ecx = window width - 1
mov eax, pixelWidth
dec eax ; eax = pixelWidth - 1
mov ebx, rcc.right ; ebx = client width - 1
sub ebx, eax ; ebx = difference
sub ecx, ebx ; adjust width
mov edx, rcw.bottom ; edx = window height - 1
sub edx, rcw.top
mov eax, pixelHeight
dec eax ; eax = pixelHeight - 1
mov ebx, rcc.bottom ; ebx = client height - 1
sub ebx, eax ; ebx = difference
sub edx, ebx ; adjust height
invoke MoveWindow, hwnd, rcw.left, rcw.top, ecx, edx, TRUE
ret
SetClientSize endp
Hello
Thanks, but the different between our procedures is not so much. I ask me why you sub 1 from width & height.
I hoped for a WinApi function. I tried it with AdjustWindowRect, but with wrong result.
Best Regards, Thomas
QuoteI ask me why you sub 1 from width & height.
Because the coordinates are 0-based and I'm setting the client width and height. If I pass your procedure 400, 300 the client area is set to 401x301, where for my procedure the client area is set to 400x300.
I also started out looking for an API function, but I could not find one that I was satisfied with.
QuoteIf I pass your procedure 400, 300 the client area is set to 401x301, where for my procedure the client area is set to 400x300.
So, when I use the Win Api function GetClientRect after my procedure, I receive 400x300. This is also Zero Based?
I will try it with vector graphic.
Thanks a lot
Thomas