How to get a child window rect relative to the parent window's client erea?
Posted on 2004-04-27 04:58:20 by Vaxon

invoke GetClientRect,hwnd,ADDR rc

: I would call this function on both, the child and the main window and respectavly calculate the positioning through rc.. Subtracking effective rc. data from each other. Just watch out it the child window does not have negative x and y co-ordinates.

Posted on 2004-04-27 05:08:35 by Black iCE
So and rect.left for a child's client erea are not 0?
Posted on 2004-04-27 05:21:42 by Vaxon
sometimes when i use common control, i use -ve values to get it lookin good. like at my Rebar posts.

Your question, only when you draw your own controls.
Posted on 2004-04-27 05:29:18 by Black iCE

The GetClientRect function retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).
Posted on 2004-04-27 09:29:57 by f0dder
invoke GetClientRect, [hChild], offset rect

invoke MapWindowPoints, [hChild], [hParent], offset rect, 1 ; for x,y,cx,cy
invoke MapWindowPoints, [hChild], [hParent], offset rect, 2 ; for x,y,x2,y2

cx,cy are the width and height of the child
x2,y2 are the coodinates in parent coordinates of the lower right corner of the child

You use the one you need for the particular application.
Posted on 2004-04-27 09:32:05 by donkey
Thank you. I needed that for a tooltip window. It seems to be much easier to pass window handle instead of an id and leave rect blank in the TOOLINFO structure to add a tool.
Posted on 2004-04-28 05:39:47 by Vaxon