Windows下Win32获取对话框子控件在对话框的相对坐标
LPRECT ScreenToDialog(HWND hWnd, LPRECT lpRect, INT nRectNum)
{
for (SIZE_T i = 0; i < nRectNum * sizeof(RECT) / sizeof(POINT); i++)
{
::ScreenToClient(hWnd, &((LPPOINT)lpRect)[i]);
}
return lpRect;
}
LPPOINT ScreenToClient(HWND hWnd, LPPOINT lpPoint, INT nPointNum)
{
for (SIZE_T i = 0; i < nPointNum; i++)
{
::ScreenToClient(hWnd, &((LPPOINT)lpPoint)[i]);
}
return lpPoint;
}
LPRECT GetDlgItemRgect(RECT& rcRect, HWND hWnd, INT nIDWndItem)
{
::GetWindowRect(::GetDlgItem(hWnd, nIDWndItem), &rcRect);
return ScreenToDialog(hWnd, &rcRect, sizeof(rcRect)/sizeof(RECT));
}