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::GetFocus method

Retrieves the element in this fragment that has the input focus.

Syntax


HRESULT GetFocus(
  [out, retval] IRawElementProviderFragment **pRetVal
);

Parameters

pRetVal [out, retval]

Type: IRawElementProviderFragment**

Receives a pointer to the IRawElementProviderFragment interface of the element in this fragment that has the input focus, if any; otherwise NULL. This parameter is passed uninitialized.

Return value

Type: HRESULT

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

Examples

The following example implementation for a list box returns the UI Automation provider for the list item that has the focus. GetItemByIndex is a member function that retrieves the provider for the item at the specified position, which is stored in a member variable of the control object.


HRESULT STDMETHODCALLTYPE ListProvider::GetFocus(IRawElementProviderFragment** pRetVal)
{
    if (pRetVal == NULL) 
    {
        return E_INVALIDARG;
    }
    ListItemProvider* pItem = GetItemByIndex(m_pControl->m_focusedItem); 
    pItem->AddRef();
    *pRetVal = (IRawElementProviderFragment*)pItem;
    return S_OK;
}           

Requirements

Minimum supported client

Windows XP [desktop apps | UWP apps]

Minimum supported server

Windows Server 2003 [desktop apps | UWP apps]

Header

UIAutomationCore.h (include UIAutomation.h)

IDL

UIAutomationCore.idl

See also

IRawElementProviderFragmentRoot

 

 

Show:
© 2017 Microsoft