TransformPattern.TransformPatternInformation.CanResize プロパティ

定義

UI オートメーションUI Automation要素のサイズが変更可能かどうかを指定する値を取得します。Gets a value that specifies whether the UI オートメーションUI Automation element can be resized.

public:
 property bool CanResize { bool get(); };
public bool CanResize { get; }
member this.CanResize : bool
Public ReadOnly Property CanResize As Boolean

プロパティ値

要素のサイズを変更できる場合は true。変更できない場合は falsetrue if the element can be resized; otherwise false.

次の例TransformPatternでは、コントロールパターンをAutomationElementから取得し、その後、のAutomationElementサイズを変更するために使用します。In the following example, a TransformPattern control pattern is obtained from an AutomationElement and subsequently used to resize the AutomationElement.

///--------------------------------------------------------------------
/// <summary>
/// Obtains a TransformPattern control pattern from 
/// an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A TransformPattern object.
/// </returns>
///--------------------------------------------------------------------
private TransformPattern GetTransformPattern(
    AutomationElement targetControl)
{
    TransformPattern transformPattern = null;

    try
    {
        transformPattern =
            targetControl.GetCurrentPattern(TransformPattern.Pattern)
            as TransformPattern;
    }
    catch (InvalidOperationException)
    {
        // object doesn't support the TransformPattern control pattern
        return null;
    }

    return transformPattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a TransformPattern control pattern from 
''' an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A TransformPattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetTransformPattern( _
ByVal targetControl As AutomationElement) As TransformPattern
    Dim transformPattern As TransformPattern = Nothing

    Try
        transformPattern = DirectCast( _
        targetControl.GetCurrentPattern(transformPattern.Pattern), _
        TransformPattern)
    Catch exc As InvalidOperationException
        ' object doesn't support the TransformPattern control pattern
        Return Nothing
    End Try

    Return transformPattern

End Function 'GetTransformPattern    
///--------------------------------------------------------------------
/// <summary>
/// Calls the TransformPattern.Resize() method for an associated 
/// automation element.
/// </summary>
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from
/// an automation element.
/// </param>
/// <param name="width">
/// The requested width of the automation element.
/// </param>
/// <param name="height">
/// The requested height of the automation element.
/// </param>
///--------------------------------------------------------------------
private void ResizeElement(
    TransformPattern transformPattern, double width, double height)
{
    try
    {
        if (transformPattern.Current.CanResize)
        {
            transformPattern.Resize(width, height);
        }
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action
        return;
    }
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TransformPattern.Resize() method for an associated 
''' automation element.
''' </summary>
''' <param name="transformPattern">
''' The TransformPattern control pattern obtained from
''' an automation element.
''' </param>
''' <param name="width">
''' The requested width of the automation element.
''' </param>
''' <param name="height">
''' The requested height of the automation element.
''' </param>
'''--------------------------------------------------------------------
Private Sub ResizeElement( _
ByVal transformPattern As TransformPattern, _
ByVal width As Double, ByVal height As Double)
    Try
        If transformPattern.Current.CanResize Then
            transformPattern.Resize(width, height)
        End If
    Catch
        ' object is not able to perform the requested action
        Return
    End Try

End Sub

注釈

オブジェクトを移動、サイズ変更、または回転することはできません。その結果、画面の位置がコンテナーの座標の外側になり、キーボードやマウスでアクセスできなくなります。An object cannot be moved, resized, or rotated such that its resulting screen location would be completely outside the coordinates of its container and inaccessible to keyboard or mouse. たとえば、最上位レベルのウィンドウが画面外に移動した場合や、子オブジェクトがコンテナーのビューポートの境界の外側に移動された場合などです。For example, when a top-level window is moved completely off-screen or a child object is moved outside the boundaries of the container's viewport. このような場合、オブジェクトは、最上位または左の座標がコンテナーの境界内でオーバーライドされ、要求された画面座標の近くに配置されます。In these cases the object is placed as close to the requested screen coordinates as possible with the top or left coordinates overridden to be within the container boundaries.

適用対象