當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET TextPatternRange.GetChildren方法代碼示例

本文整理匯總了VB.NET中System.Windows.Automation.Text.TextPatternRange.GetChildren方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET TextPatternRange.GetChildren方法的具體用法?VB.NET TextPatternRange.GetChildren怎麽用?VB.NET TextPatternRange.GetChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了TextPatternRange.GetChildren方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: StartTarget

''' -------------------------------------------------------------------
''' <summary>
''' Starts the target application and returns the AutomationElement 
''' obtained from the targets window handle.
''' </summary>
''' <param name="exe">
''' The target application.
''' </param>
''' <param name="filename">
''' The text file to be opened in the target application
''' </param>
''' <returns>
''' An AutomationElement representing the target application.
''' </returns>
''' -------------------------------------------------------------------
Private Function StartTarget( _
ByVal exe As String, ByVal filename As String) As AutomationElement
    ' Start text editor and load with a text file.
    Dim p As Process = Process.Start(exe, filename)

    ' targetApp --> the root AutomationElement.
    Dim targetApp As AutomationElement
    targetApp = AutomationElement.FromHandle(p.MainWindowHandle)

    Return targetApp
End Function
開發者ID:VB.NET開發者,項目名稱:System.Windows.Automation.Text,代碼行數:26,代碼來源:TextPatternRange.GetChildren

示例2: GetTextElement

''' -------------------------------------------------------------------
''' <summary>
''' Obtain the text control of interest from the target application.
''' </summary>
''' <param name="targetApp">
''' The target application.
''' </param>
''' <returns>
''' An AutomationElement. representing a text control.
''' </returns>
''' -------------------------------------------------------------------
Private Function GetTextElement(ByVal targetApp As AutomationElement) As AutomationElement
    ' The control type we're looking for; in this case 'Document'
    Dim cond1 As PropertyCondition = _
        New PropertyCondition( _
        AutomationElement.ControlTypeProperty, _
        ControlType.Document)

    ' The control pattern of interest; in this case 'TextPattern'.
    Dim cond2 As PropertyCondition = _
        New PropertyCondition( _
        AutomationElement.IsTextPatternAvailableProperty, _
        True)

    Dim textCondition As AndCondition = New AndCondition(cond1, cond2)

    Dim targetTextElement As AutomationElement = _
        targetApp.FindFirst(TreeScope.Descendants, textCondition)

    ' If targetText is null then a suitable text control was not found.
    Return targetTextElement
End Function
開發者ID:VB.NET開發者,項目名稱:System.Windows.Automation.Text,代碼行數:32,代碼來源:TextPatternRange.GetChildren

示例3: GetEmbeddedObjects

''' -------------------------------------------------------------------
''' <summary>
''' Retrieves the embedded children of a document control.
''' </summary>
''' <param name="targetTextElement">
''' The AutomationElement. representing a text control.
''' </param>
''' -------------------------------------------------------------------
Private Sub GetEmbeddedObjects( _
ByVal targetTextElement As AutomationElement)
    Dim textPattern As TextPattern = _
    DirectCast(targetTextElement.GetCurrentPattern(textPattern.Pattern), TextPattern)

    If (textPattern Is Nothing) Then
        ' Target control doesn't support TextPattern.
        Return
    End If

    ' Obtain a text range spanning the entire document.
    Dim textRange As TextPatternRange = textPattern.DocumentRange

    ' Retrieve the embedded objects within the range.
    Dim embeddedObjects() As AutomationElement = textRange.GetChildren()

    Dim embeddedObject As AutomationElement
    For Each embeddedObject In embeddedObjects
        Console.WriteLine(embeddedObject.Current.Name)
    Next
End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Automation.Text,代碼行數:29,代碼來源:TextPatternRange.GetChildren


注:本文中的System.Windows.Automation.Text.TextPatternRange.GetChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。