CPoint ptScreen(pMsg->lParam);
CRect rect;
::GetWindowRect(pMsg->hwnd, &rect);
if (rect.PtInRect(ptScreen))
{
return FALSE;
}
HWND hParent = ::GetDesktopWindow();
while (true)
{
CPoint ptClient = ptScreen;
::ScreenToClient(hParent, &ptClient);
HWND hChild = ChildWindowFromPointEx(hParent, ptClient, CWP_SKIPDISABLED | CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
if (hChild == NULL || hChild == hParent)
{
break;
}
else
{
hParent = hChild;
}
}
if (hParent != ::GetDesktopWindow() && hParent != pMsg->hwnd)
{
DWORD dwProcessID = 0;
GetWindowThreadProcessId(hParent, &dwProcessID);
if (dwProcessID == GetCurrentProcessId())
{
::SendMessage(hParent, pMsg->message, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
return FALSE;
拿到第一个子窗体并发送消息
最新推荐文章于 2018-06-05 18:41:45 发布