TreeWalker.GetFirstChild 메서드

정의

지정된 AutomationElement의 첫 번째 자식 요소를 검색합니다.

오버로드

GetFirstChild(AutomationElement)

지정된 AutomationElement의 첫 번째 자식 요소를 검색합니다.

GetFirstChild(AutomationElement, CacheRequest)

지정된 AutomationElement의 첫 번째 자식 요소를 검색하고 속성 및 패턴을 캐시합니다.

설명

AutomationElement 현재 뷰 상태를 일치 하지 않습니다 하 고 요소 트리를 탐색할 때 반환 되지 않는 추가 자식 요소가 있을 수 있습니다.

트리의 AutomationElement 구조는 바탕 화면에 표시되는 UI(사용자 인터페이스) 요소가 변경됨에 따라 변경됩니다. 반환 된 요소가 다음 번에 첫 번째 자식 요소를 첫 번째 자식으로 반환 됩니다는 보장 되지 않습니다.

GetFirstChild(AutomationElement)

지정된 AutomationElement의 첫 번째 자식 요소를 검색합니다.

public:
 System::Windows::Automation::AutomationElement ^ GetFirstChild(System::Windows::Automation::AutomationElement ^ element);
public System.Windows.Automation.AutomationElement GetFirstChild (System.Windows.Automation.AutomationElement element);
member this.GetFirstChild : System.Windows.Automation.AutomationElement -> System.Windows.Automation.AutomationElement
Public Function GetFirstChild (element As AutomationElement) As AutomationElement

매개 변수

element
AutomationElement

첫 번째 자식을 검색할 요소입니다.

반환

AutomationElement

첫 번째 자식 요소이거나, 이러한 요소가 없는 경우 null 참조(Visual Basic의 경우 Nothing)입니다.

예제

다음 예제에서는 GetFirstChild 하위 트리의 요소 트리 뷰를 생성 하는 데 사용 되 고 있습니다.

/// <summary>
/// Walks the UI Automation tree and adds the control type of each element it finds 
/// in the control view to a TreeView.
/// </summary>
/// <param name="rootElement">The root of the search on this iteration.</param>
/// <param name="treeNode">The node in the TreeView for this iteration.</param>
/// <remarks>
/// This is a recursive function that maps out the structure of the subtree beginning at the
/// UI Automation element passed in as rootElement on the first call. This could be, for example,
/// an application window.
/// CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
/// the desktop could take a very long time and even lead to a stack overflow.
/// </remarks>
private void WalkControlElements(AutomationElement rootElement, TreeNode treeNode)
{
    // Conditions for the basic views of the subtree (content, control, and raw) 
    // are available as fields of TreeWalker, and one of these is used in the 
    // following code.
    AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(rootElement);

    while (elementNode != null)
    {
        TreeNode childTreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType);
        WalkControlElements(elementNode, childTreeNode);
        elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
    }
}
''' <summary>
''' Walks the UI Automation tree and adds the control type of each element it finds 
''' in the control view to a TreeView.
''' </summary>
''' <param name="rootElement">The root of the search on this iteration.</param>
''' <param name="treeNode">The node in the TreeView for this iteration.</param>
''' <remarks>
''' This is a recursive function that maps out the structure of the subtree beginning at the
''' UI Automation element passed in as rootElement on the first call. This could be, for example,
''' an application window.
''' CAUTION: Do not pass in AutomationElement.RootElement. Attempting to map out the entire subtree of
''' the desktop could take a very long time and even lead to a stack overflow.
''' </remarks>
Private Sub WalkControlElements(ByVal rootElement As AutomationElement, ByVal treeNode As TreeNode)
    ' Conditions for the basic views of the subtree (content, control, and raw) 
    ' are available as fields of TreeWalker, and one of these is used in the 
    ' following code.
    Dim elementNode As AutomationElement = TreeWalker.ControlViewWalker.GetFirstChild(rootElement)

    While (elementNode IsNot Nothing)
        Dim childTreeNode As TreeNode = treeNode.Nodes.Add(elementNode.Current.ControlType.LocalizedControlType)
        WalkControlElements(elementNode, childTreeNode)
        elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode)
    End While

End Sub

설명

AutomationElement 현재 뷰 상태를 일치 하지 않습니다 하 고 요소 트리를 탐색할 때 반환 되지 않는 추가 자식 요소가 있을 수 있습니다.

트리의 AutomationElement 구조는 바탕 화면에 표시되는 UI(사용자 인터페이스) 요소가 변경됨에 따라 변경됩니다. 반환 된 요소가 다음 번에 첫 번째 자식 요소를 첫 번째 자식으로 반환 됩니다는 보장 되지 않습니다.

추가 정보

적용 대상

GetFirstChild(AutomationElement, CacheRequest)

지정된 AutomationElement의 첫 번째 자식 요소를 검색하고 속성 및 패턴을 캐시합니다.

public:
 System::Windows::Automation::AutomationElement ^ GetFirstChild(System::Windows::Automation::AutomationElement ^ element, System::Windows::Automation::CacheRequest ^ request);
public System.Windows.Automation.AutomationElement GetFirstChild (System.Windows.Automation.AutomationElement element, System.Windows.Automation.CacheRequest request);
member this.GetFirstChild : System.Windows.Automation.AutomationElement * System.Windows.Automation.CacheRequest -> System.Windows.Automation.AutomationElement
Public Function GetFirstChild (element As AutomationElement, request As CacheRequest) As AutomationElement

매개 변수

element
AutomationElement

첫 번째 자식을 검색할 요소입니다.

request
CacheRequest

반환된 AutomationElement에서 캐시할 속성 및 패턴을 지정하는 캐시 요청 개체입니다.

반환

AutomationElement

첫 번째 자식 요소이거나, 이러한 요소가 없는 경우 null 참조(Visual Basic의 경우 Nothing)입니다.

설명

AutomationElement 현재 뷰 상태를 일치 하지 않습니다 하 고 요소 트리를 탐색할 때 반환 되지 않는 추가 자식 요소가 있을 수 있습니다.

트리의 AutomationElement 구조는 바탕 화면에 표시되는 UI(사용자 인터페이스) 요소가 변경됨에 따라 변경됩니다. 반환 된 요소가 다음 번에 첫 번째 자식 요소를 첫 번째 자식으로 반환 됩니다는 보장 되지 않습니다.

추가 정보

적용 대상