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 | Windows Store apps] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps | Windows Store apps] |
|
Header |
|
|
IDL |
|
See also