AutomationInteropProvider.RaiseStructureChangedEvent 메서드

정의

UI 자동화 트리가 변경되면 이벤트를 발생합니다.

public:
 static void RaiseStructureChangedEvent(System::Windows::Automation::Provider::IRawElementProviderSimple ^ provider, System::Windows::Automation::StructureChangedEventArgs ^ e);
public static void RaiseStructureChangedEvent (System.Windows.Automation.Provider.IRawElementProviderSimple provider, System.Windows.Automation.StructureChangedEventArgs e);
static member RaiseStructureChangedEvent : System.Windows.Automation.Provider.IRawElementProviderSimple * System.Windows.Automation.StructureChangedEventArgs -> unit
Public Shared Sub RaiseStructureChangedEvent (provider As IRawElementProviderSimple, e As StructureChangedEventArgs)

매개 변수

provider
IRawElementProviderSimple

이벤트와 연결된 요소입니다.

e
StructureChangedEventArgs

이벤트 정보입니다.

예제

다음 예제에서는 자식으로 추가 되 면 이벤트를 발생 시키는 방법을 보여 줍니다. 또는 사용자 지정 목록 상자에서 제거 합니다.

/// <summary>
/// Responds to an addition to the UI Automation tree structure by raising an event.
/// </summary>
/// <param name="list">
/// The list to which the item was added.
/// </param>
/// <remarks>
/// For the runtime Id of the item, pass 0 because the provider cannot know
/// what its actual runtime Id is.
/// </remarks>
public static void OnStructureChangeAdd(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkAdded, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}

/// <summary>
/// Responds to a removal from the UI Automation tree structure 
/// by raising an event.
/// </summary>
/// <param name="list">
/// The list from which the item was removed.
/// </param>
/// <remarks>
/// For the runtime Id of the list, pass 0 because the provider cannot know
/// what its actual runtime ID is.
/// </remarks>
public static void OnStructureChangeRemove(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkRemoved, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}
''' <summary>
''' Responds to an addition to the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list to which the item was added.
''' </param>
''' <remarks>
''' For the runtime Id of the item, pass 0 because the provider cannot know
''' what its actual runtime Id is.
''' </remarks>
Public Shared Sub OnStructureChangeAdd(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkAdded, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub


''' <summary>
''' Responds to a removal from the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list from which the item was removed.
''' </param>
''' <remarks>
''' For the runtime Id of the list, pass 0 because the provider cannot know
''' what its actual runtime ID is.
''' </remarks>
Public Shared Sub OnStructureChangeRemove(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkRemoved, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub

설명

트리 구조의 변경의 예에 추가할 자식 요소 또는 목록 상자에서 제거 또는 되 확장 또는 축소 트리 보기에서.

런타임 식별자, 요소 또는 해당 컨테이너에 전달 되는 자식 요소가 제거 되 면는 StructureChangedEventArgs 생성자입니다. 그러나 현재 버전의 UI 자동화에서는 공급자의 instance 런타임 식별자를 검색하는 쉬운 방법이 없습니다. 메서드는 GetRuntimeId 일반적으로 포함 된 배열을 AppendRuntimeId반환 , 컨트롤의 모든 instance 대 한 고유 한 identifer를 만들도록 UI 자동화 시스템을 지시 하는 매직 번호. 제공한 원시 값 GetRuntimeId 해서는 안 이벤트, 고 있기 때문에 클라이언트에 게 의미가 특정 인스턴스를 식별 하는 사용할 수 없습니다.

형식의 이벤트는이 제한으로 인해 ChildAddedChildRemoved 그리 유용 하지 않습니다. 대신 항상 사용 ChildrenBulkAddedChildrenBulkRemoved, 런타임 식별자로 0을 전달 합니다. 사용할 수 없습니다 null처럼이 예외를 발생 시킵니다. 클라이언트 알림이 표시 됩니다는 변경 된 내용이 컨테이너에서 (로 식별 되는 sender 매개 변수가 전달 되는 StructureChangedEventHandler) 어떤 자식에 대 한 특정 공지 추가 되었거나 제거 하지 않고, 합니다.

적용 대상

추가 정보