What is the best way to find the position of a control relative to its parent window?

There are at least 2 ways to do this AFAIK.

How to find the position of a Win32 control relative to its parent window?

and this:

How to get the size and location of a control placed in a dialog box 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 method is better and why? Is the method with MapWindowPointswork with multiple monitors?

My concern is mainly related to MapWindowPoints, and multi-monitor, since the transfer 0as hWndFromwill be usedHWND_DESKTOP

+4
source share
1 answer

@TLama , . (!:))


(1) ScreenToClien , , WS_EX_LAYOUTRTL, .

(2) MapWindowPoints .

, WS_EX_LAYOUTRTL.

.

+3

All Articles