HWND GetChildMost(const POINT& ptScreen)
{
HWND hWndFind = WindowFromPoint(ptScreen);
if (hWndFind == NULL)
return NULL;
HWND parent = ::GetParent(hWndFind);
if (parent == NULL)
return NULL;
HWND hWndChild = NULL;
hWndFind = parent;
CPoint ptClient = ptScreen;
::ScreenToClient(parent, &ptClient);
//从最上层的窗口开始外下找,只直到找到最底层的窗口
while (TRUE) {
hWndChild = RealChildWindowFromPoint(hWndFind, ptClient);
if (hWndChild && (hWndChild != hWndFind))
hWndFind = hWndChild;
else
break;
}
return hWndFind;
}