CWnd::ChildWindowFromPoint

Determines which, if any, of the child windows belonging to CWnd contains the specified point.

CWnd* ChildWindowFromPoint(
   POINT point 
) const;
CWnd* ChildWindowFromPoint(
   POINT point,
   UINT nFlags 
) const;

Parameters

  • point
    Specifies the client coordinates of the point to be tested.

  • nflags
    Specifies which child windows to skip. This parameter can be a combination of the following values:

    Value

    Meaning

    CWP_ALL

    Do not skip any child windows

    CWP_SKIPINVISIBLE

    Skip invisible child windows

    CWP_SKIPDISABLED

    Skip disabled child windows

    CWP_SKIPTRANSPARENT

    Skip transparent child windows

Return Value

Identifies the child window that contains the point. It is NULL if the given point lies outside of the client area. If the point is within the client area but is not contained within any child window, CWnd is returned.

This member function will return a hidden or disabled child window that contains the specified point.

More than one window may contain the given point. However, this function returns only the CWnd* of the first window encountered that contains the point.

The CWnd* that is returned may be temporary and should not be stored for later use.

Example

void CMyDlg::OnFindCenterChild() 
{
   CRect rect;
   GetClientRect(&rect);
   CWnd* pWnd = ChildWindowFromPoint(
      CPoint(rect.Width()/2, rect.Height()/2), 
      // Top left is always 0, 0.
      CWP_SKIPINVISIBLE);
   TRACE(_T("Center window is 0x%08x\n"), pWnd->m_hWnd);
}

Requirements

Header: afxwin.h

See Also

Reference

CWnd Class

Hierarchy Chart

CWnd::WindowFromPoint

ChildWindowFromPoint

Concepts

CWnd Members