There are at-least 2 ways of doing this AFAIK.
How do I find position of a Win32 control/window relative to its parent window?
and this:
How to get size and location of a control placed on a dialog in MFC?
htext := GetDlgItem(hDlg, IDI_TEXT);
GetWindowRect(htext, R);
// (1)
// Pt := Point(R.Left, R.Top);
// ScreenToClient(hDlg, Pt);
// R := Rect(Pt.X, Pt.Y, Pt.X + R.Right - R.Left, Pt.Y + R.Bottom - R.Top);
// OR: (2)
MapWindowPoints(0, {GetParent(htext)} hDlg, R, 2);
FrameRect(dc, R, brush);
Which of the methods is better and why? Is the method with MapWindowPoints
will work with multiple monitors?
My concern is mainly with MapWindowPoints
and multi-monitors since passing 0
as hWndFrom
will use the HWND_DESKTOP