I want to create a window which has a client area of a given size and then to create a region limited to the client area of the window. I use AdjustWindowRectEx to get the dimensions of the window but how do I create the region? I mean, how do I get the coordinates of the client area within a window? ClientToScreen gives absolute coordinates only. Should I use it on client area, then on the window and calculate desired values or is there any better solution?
Posted on 2004-05-26 13:56:24 by marcinbu
IMHO the only solution would be to create the window first, then resize it however you wish and create the region when processing WM_CREATE.

Just make sure not to use the WS_VISIBLE style flag. That way you can call ShowWindow when you're done resizing.

Hope that helps :)
Posted on 2004-05-26 17:08:38 by QvasiModo
invoke ClientToScreen, hWnd, ADDR Rect
invoke MapWindowPoints, HWND_DESKTOP, hWnd, ADDR Rect, 2

Is this what your looking to do?
Posted on 2004-05-26 21:19:20 by Graebel
Posted on 2004-05-27 04:14:16 by Homer
GetClientRect won't help - it returns a rectangle like {0,0,width,height} and I need coordinates of the client area relative to its window. So MapWindowPoints won't do either becase I've got the handle of the window, not the client area I guess. Or am I wrong?
Posted on 2004-05-27 13:30:43 by marcinbu
Hmm lemme see. No your right, that didnt do what I thought it should do.


; get window - {x1, y1, x2, y2}
invoke GetWindowRect, hWnd, ADDR Rect1

; get client - {0, 0, w, h}
invoke GetClientRect, hWnd, ADDR Rect2
; convert to - {x1, y1, w, h}
invoke ClientToScreen, hWnd, Rect2

; convert to - {DeltaX, DeltaY, w, h}
mov eax, Rect2.left
sub eax, Rect1.left
mov Rect2.left, eax
mov eax, Rect2.top
sub eax, Rect1.top
mov Rect2.top, eax

; convert to - { DeltaX, DeltaY, DeltaX2, DeltaY2 }
mov eax, Rect2.left
add eax, Rect2.right
mov Rect2.right, eax
mov eax, Rect2.top
add eax, Rect2.bottom
mov Rect2.bottom, eax

; done - answer in Rect2
; Note: not tested, but something along those lines should work
Posted on 2004-05-27 21:38:50 by Graebel