v1.1:
Code: Select all
// The given point must be inside aWnd's bounds. Then, if there is no hwnd found yet or if aWnd
// is entirely contained within the previously found hwnd, update to a "better" found window like
// Window Spy. This overcomes the limitations of WindowFromPoint() and ChildWindowFromPoint():
if (pah.pt.x >= rect.left && pah.pt.x <= rect.right && pah.pt.y >= rect.top && pah.pt.y <= rect.bottom)
{
Code: Select all
// The given point must be inside aWnd's bounds. Then, if there is no hwnd found yet or if aWnd
// is entirely contained within the previously found hwnd, update to a "better" found window like
// Window Spy. This overcomes the limitations of WindowFromPoint() and ChildWindowFromPoint().
// The pixel at (left, top) lies inside the control, whereas MSDN says "the pixel at (right, bottom)
// lies immediately outside the rectangle" -- so use < instead of <= below:
if (pah.pt.x >= rect.left && pah.pt.x < rect.right && pah.pt.y >= rect.top && pah.pt.y < rect.bottom)
{