Uredi

Deli z drugimi prek


IRawElementProviderAdviseEvents.AdviseEventAdded(Int32, Int32[]) Method

Definition

Notifies the UI Automation provider when a UI Automation client begins listening for a specific event, including a property-changed event.

public:
 void AdviseEventAdded(int eventId, cli::array <int> ^ properties);
public void AdviseEventAdded (int eventId, int[] properties);
abstract member AdviseEventAdded : int * int[] -> unit
Public Sub AdviseEventAdded (eventId As Integer, properties As Integer())

Parameters

eventId
Int32

The identifier of the event being added.

properties
Int32[]

The identifiers of the properties being added, or null if the event listener being added is not listening for property events.

Examples

The following example adds to a list of property changes that have been subscribed to.

void IRawElementProviderAdviseEvents.AdviseEventAdded(int eventId, 
                                                      int[] properties)
{
    if (eventId == AutomationElement.AutomationPropertyChangedEvent.Id)
    {
        foreach (int i in properties)
        {
            AutomationProperty property = AutomationProperty.LookupById(i);
            // Add to an ArrayList.
            subscribedProperties.Add(property);
        }
    }
}
Sub AdviseEventAdded(ByVal eventId As Integer, ByVal properties() As Integer) _
    Implements IRawElementProviderAdviseEvents.AdviseEventAdded

    If eventId = AutomationElement.AutomationPropertyChangedEvent.Id Then
        For Each i As Integer In properties
            Dim autoProperty As AutomationProperty = AutomationProperty.LookupById(i)
            ' Add to an ArrayList.
            subscribedProperties.Add(autoProperty)
        Next
    End If

End Sub

Remarks

This method enables the provider to reduce overhead by raising only events that are being listened for.

The eventId can be compared with the Id of an AutomationEvent such as WindowClosedEvent. You can also obtain the AutomationEvent by using LookupById.

Applies to