Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IRawElementProviderFragmentRoot::ElementProviderFromPoint method

Retrieves the provider of the element that is at the specified point in this fragment.

Syntax


HRESULT ElementProviderFromPoint(
  [in]          double                      x,
  [in]          double                      y,
  [out, retval] IRawElementProviderFragment **pRetVal
);

Parameters

x [in]

Type: double

The horizontal screen coordinate.

y [in]

Type: double

The vertical screen coordinate.

pRetVal [out, retval]

Type: IRawElementProviderFragment**

Receives a pointer to the provider of the element at (x, y), or NULL if none exists. This parameter is passed uninitialized.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The returned provider should correspond to the element that would receive mouse input at the specified point.

If the point is on this element but not on any child element, either NULL or the provider of the fragment root is returned. If the point is on an element in another framework that is hosted by this fragment, the method returns the element that hosts that fragment (as indicated by IRawElementProviderFragment::GetEmbeddedFragmentRoots).

Examples

The following example shows an implementation for a list box hosted in an HWND whose handle is m_controlHwnd. IndexFromY retrieves the index of the list item at the cursor position, and GetItemByIndex retrieves the UI Automation provider for that item.


HRESULT STDMETHODCALLTYPE ListProvider::ElementProviderFromPoint(double x, double y, IRawElementProviderFragment** pRetVal)
{
    if (pRetVal == NULL) 
    {
        return E_INVALIDARG;
    }
    POINT pt;
    pt.x = (LONG)x;
    pt.y = (LONG)y;
    ScreenToClient(m_controlHwnd, &pt);
    int itemIndex = this->m_pControl->IndexFromY(m_controlHwnd, pt.y);
    ListItemProvider* pItem = GetItemByIndex(itemIndex);  
    if (pItem != NULL)
    {
        *pRetVal = (IRawElementProviderFragment*)pItem;
        pItem->AddRef();
    }
    else 
    {
        pRetVal = (IRawElementProviderFragment*)this;
        pItem->AddRef();
    }

    return S_OK;
}            

Requirements

Minimum supported client

Windows XP [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

UIAutomationCore.h (include UIAutomation.h)

IDL

UIAutomationCore.idl

See also

IRawElementProviderFragmentRoot

 

 

Show:
© 2017 Microsoft