TextPattern.FontWeightAttribute 필드

정의

텍스트 범위의 FontWeight 특성을 식별합니다.

public: static initonly System::Windows::Automation::AutomationTextAttribute ^ FontWeightAttribute;
public static readonly System.Windows.Automation.AutomationTextAttribute FontWeightAttribute;
 staticval mutable FontWeightAttribute : System.Windows.Automation.AutomationTextAttribute
Public Shared ReadOnly FontWeightAttribute As AutomationTextAttribute 

필드 값

AutomationTextAttribute

예제

다음 예제에서는 Microsoft 메모장의 텍스트 범위에 대 한 특성 값을 가져오는 방법을 보여 줍니다.

참고

Microsoft 메모장 텍스트 공급자 예를 들어 목적 으로만 사용 됩니다. 요청 된 특성 값을 지원 하도록 Microsoft 메모장 보장 되지 않습니다.

private void GetFontWeightAttribute()
{
    // Start application.
    Process p = Process.Start("Notepad.exe", "text.txt");

    // target --> The root AutomationElement.
    AutomationElement target = AutomationElement.FromHandle(p.MainWindowHandle);

    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return;
    }

    Object oAttribute = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.FontWeightAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixed font weights.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}
Private Sub GetFontWeightAttribute()
    ' Start application.
    Dim p As Process = Process.Start("Notepad.exe", "text.txt")

    ' target --> The root AutomationElement.
    Dim target As AutomationElement = AutomationElement.FromHandle(p.MainWindowHandle)

    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return
    End If

    Dim oAttribute As Object = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.FontWeightAttribute)
    If (oAttribute = TextPattern.MixedAttributeValue) Then
        Console.WriteLine("Mixed font weights.")
    Else
        Console.WriteLine(oAttribute.ToString())
    End If
End Sub

설명

이 특성이 상대 스트로크, 두께 또는 글꼴의 굵기를 참조합니다.

이 특성은 lfWeight GDI LOGFONT 필드입니다. 일관성을 위해 다음 값을 받아 들였습니다 LOGFONT에서: 0 DontCare, 100 = Thin, 200 = = ExtraLight 또는 초경량, 300 빛을 400 = Normal 또는 일반, 500 = = 보통, 600 = SemiBold 또는 DemiBold, 700 굵게 하십시오 800 = = ExtraBold 또는 UltraBold, 및 900 많거나 검정 =.

이 식별자는 UI 자동화 클라이언트 애플리케이션에서 사용 됩니다. UI 자동화 공급자의 해당 필드를 사용 해야 TextPatternIdentifiers합니다.

UI 자동화 클라이언트를 호출 하 여 특성의 값을 가져올 GetAttributeValue합니다.

이 특성의 값은 형식의 Int32합니다. 기본값은 zero입니다.

적용 대상

추가 정보