IRawElementProviderAdviseEvents.AdviseEventAdded(Int32, Int32[]) Metoda

Definicja

Powiadamia dostawcę automatyzacja interfejsu użytkownika o rozpoczęciu nasłuchiwania określonego zdarzenia przez klienta automatyzacja interfejsu użytkownika, w tym zdarzenia zmienionego przez właściwość.

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())

Parametry

eventId
Int32

Identyfikator dodawanego zdarzenia.

properties
Int32[]

Identyfikatory dodawanych właściwości lub null jeśli dodawany odbiornik zdarzeń nie nasłuchuje zdarzeń właściwości.

Przykłady

Poniższy przykład dodaje do listy zmian właściwości, które zostały zasubskrybowane.

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

Uwagi

Ta metoda umożliwia dostawcy zmniejszenie nakładu pracy przez wywoływanie tylko zdarzeń, dla których są nasłuchiwane.

Element eventId można porównać z elementem Id typu AutomationEvent , takim jak WindowClosedEvent. Element można również uzyskać AutomationEvent przy użyciu polecenia LookupById.

Dotyczy