How to get Window Rect coordinates wrt to its parent window rect coordinates.
-
Dear Friends, Does anybody know how to get child Window Rect coordinates wrt to parent window Rect coordinates. [Something similar to GetRectInContainer()]. I want in SDK rather than in MFC. Thanks in advance, subramjobmail.
-
Dear Friends, Does anybody know how to get child Window Rect coordinates wrt to parent window Rect coordinates. [Something similar to GetRectInContainer()]. I want in SDK rather than in MFC. Thanks in advance, subramjobmail.
Do you mean you want the position of your client window inside the parent window?
RECT rtClient;
// Get the position of the client in screen coordinates
GetWindowRect(hClientWnd, &rtClient);
// Converts the screen coordinates to client coordinates
ScreenToClient(hClientWnd, (LPPOINT) &rtClient.left);
ScreenToClient(hClientWnd, (LPPOINT) &rtClient.right);Daniel ;) --------------------------- Never change a running system!
-
Do you mean you want the position of your client window inside the parent window?
RECT rtClient;
// Get the position of the client in screen coordinates
GetWindowRect(hClientWnd, &rtClient);
// Converts the screen coordinates to client coordinates
ScreenToClient(hClientWnd, (LPPOINT) &rtClient.left);
ScreenToClient(hClientWnd, (LPPOINT) &rtClient.right);Daniel ;) --------------------------- Never change a running system!
You understanding is correct but the code block which you have given will give only wrt to screen point. But i want wrt to parent window RECT of hClientWnd. It should proper values (-ve values) if scrolled [partially visible] Something like how GetRectInContainer() gives in OCX wrt to IE
-
You understanding is correct but the code block which you have given will give only wrt to screen point. But i want wrt to parent window RECT of hClientWnd. It should proper values (-ve values) if scrolled [partially visible] Something like how GetRectInContainer() gives in OCX wrt to IE
But the
ScreenToClient
method will convert the screen coordinates to client coordinates! Daniel ;) --------------------------- Never change a running system! -
But the
ScreenToClient
method will convert the screen coordinates to client coordinates! Daniel ;) --------------------------- Never change a running system!But i want functionality some thing similar to what GetRectInContainer() of COleControl class gives in OCX control.
-
But i want functionality some thing similar to what GetRectInContainer() of COleControl class gives in OCX control.
Something like this?
HWND hWndParent = ... // Handle to the parent window
HWND hWndChild = ... // Handle to the child windowASSERT(hWndParent);
ASSERT(hWndChild);RECT rt;
::GetWindowRect(hWndChild, &rt);
::MapWindowPoints(HWND_DESKTOP, hWndParent, (LPPOINT) &rt, 2);-- Cheers, Daniel ;)