IRawElementProviderFragmentRoot::GetFocus Method
Retrieves the element in this fragment that has the input focus.
Syntax
HRESULT GetFocus( IRawElementProviderFragment **pRetVal );
Parameters
- pRetVal
[out, retval] The address of a variable that 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
Returns S_OK if successful, or an error value otherwise.
Example
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; }
See Also