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 

필드 값

예제

다음 예제에서는 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

설명

이 특성은 글꼴의 상대 스트로크, 두께 또는 굵게를 나타냅니다.

이 특성은 GDI LOGFONT의 lfWeight 필드를 따라 모델링됩니다. 일관성을 위해 LOGFONT에서 0=DontCare, 100=Thin, 200=ExtraLight 또는 UltraLight, 300=Light, 400=Normal 또는 Regular, 500=Medium, 600=SemiBold 또는 DemiBold, 700=Bold, 800=ExtraBold 또는 UltraBold, 900=Heavy 또는 Black 값이 채택되었습니다.

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

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

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

적용 대상

추가 정보