我很难确定(我相信的是)客户端坐标
WM_INITDIALOG
的{{1}}消息中的(单选按钮)控件。
这是我尝试的内容:
DlgProc
我希望// Retrieve coordinates of Control with respect to the screen.
RECT rectOrthoButton;
GetWindowRect(GetDlgItem(hWnd, IDC_ORTHO), &rectOrthoButton);
// Translate coordinates to more useful coordinates: those that
// are used on the dialog.
// In order to do the translation we have to find the top left
// point (coordinates) of the dialog's client:
POINT dlgTopLeft;
ClientToScreen(hWnd, &dlgTopLeft);
// With these coordinates we can do the translation.
// We're only interested in top and left, so we skip
// bottom and right:
rectOrthoButton.top -= dlgTopLeft.y;
rectOrthoButton.left -= dlgTopLeft.x;
use_top_and_left(rectOrthoButton.top, rectOrthoButton.left);
和rectOrthoButton.top
成为我的控件相对于对话框客户区的左上角坐标。事实证明他们不是,我不确定
他们所指的.left
等于-40。
编辑:现在我被指示用
初始化POINTrectOrthoButton.left
(我愚蠢忘记了):有没有更短的方法来实现我的目标?