IUIAutomation::RemoveAutomationEventHandler method (uiautomationclient.h)

Removes the specified UI Automation event handler.

Syntax

HRESULT RemoveAutomationEventHandler(
  [in] EVENTID                   eventId,
  [in] IUIAutomationElement      *element,
  [in] IUIAutomationEventHandler *handler
);

Parameters

[in] eventId

Type: EVENTID

The identifier of the event being handled. For a list of event IDs, see Event Identifiers.

[in] element

Type: IUIAutomationElement*

A pointer to the UI Automation element that is handling the event.

[in] handler

Type: IUIAutomationEventHandler*

A pointer to the handler method that was passed to IUIAutomation::AddAutomationEventHandler for the specified event identifier and UI Automation element.

Return value

Type: HRESULT

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

Remarks

A UI Automation client should not use multiple threads to add or remove event handlers. Unexpected behavior can result if one event handler is being added or removed while another is being added or removed in the same client process.

It is possible for an event to be delivered to an event handler after the handler has been unsubscribed, if the event is received simultaneously with the request to unsubscribe the event. The best practice is to follow the Component Object Model (COM) standard and avoid destroying the event handler object until its reference count has reached zero. Destroying an event handler immediately after unsubscribing for events may result in an access violation if an event is delivered late.

Requirements

Requirement Value
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista, Windows XP with SP3 and Platform Update for Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008, Windows Server 2003 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]
Target Platform Windows
Header uiautomationclient.h (include UIAutomation.h)

See also

IUIAutomation

RemoveAllEventHandlers

RemoveFocusChangedEventHandler

RemovePropertyChangedEventHandler

RemoveStructureChangedEventHandler