TransformPattern.TransformPatternInformation.CanMove Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob das Benutzeroberflächenautomatisierung Element verschoben werden kann.

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

Eigenschaftswert

Boolean

true, wenn das Element bewegt werden kann, andernfalls false.

Beispiele

Im folgenden Beispiel wird ein TransformPattern Steuerelementmuster aus einem AutomationElement und anschließend zum Verschieben des AutomationElementSteuerelements abgerufen.

///--------------------------------------------------------------------
/// <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.Move() method for an associated 
/// automation element.
/// </summary>
/// <param name="transformPattern">
/// The TransformPattern control pattern obtained from
/// an automation element.
/// </param>
/// <param name="x">
/// The number of screen pixels to move the automation element 
/// horizontally.
/// </param>
/// <param name="y">
/// The number of screen pixels to move the automation element 
/// vertically.
/// </param>
///--------------------------------------------------------------------
private void MoveElement(
    TransformPattern transformPattern, double x, double y)
{
    try
    {
        if (transformPattern.Current.CanMove)
        {
            transformPattern.Move(x, y);
        }
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action
        return;
    }
}
'''--------------------------------------------------------------------
''' <summary>
''' Calls the TransformPattern.Move() method for an associated 
''' automation element.
''' </summary>
''' <param name="transformPattern">
''' The TransformPattern control pattern obtained from
''' an automation element.
''' </param>
''' <param name="x">
''' The number of screen pixels to move the automation element 
''' horizontally.
''' </param>
''' <param name="y">
''' The number of screen pixels to move the automation element 
''' vertically.
''' </param>
'''--------------------------------------------------------------------
Private Sub MoveElement( _
ByVal transformPattern As TransformPattern, _
ByVal x As Double, ByVal y As Double)
    Try
        If transformPattern.Current.CanMove Then
            transformPattern.Move(x, y)
        End If
    Catch exc As InvalidOperationException
        ' object is not able to perform the requested action
        Return
    End Try

End Sub

Hinweise

Ein Objekt kann nicht verschoben, geändert oder gedreht werden, sodass seine resultierende Bildschirmposition vollständig außerhalb der Koordinaten des Containers und nicht auf die Tastatur oder Maus zugegriffen werden kann. Wenn beispielsweise ein Fenster auf oberster Ebene vollständig aus dem Bildschirm verschoben wird oder ein untergeordnetes Objekt außerhalb der Grenzen des Viewports des Containers verschoben wird. In diesen Fällen wird das Objekt so nah an den angeforderten Bildschirmkoordinaten wie möglich platziert, wobei die oberen oder linken Koordinaten überschrieben werden, die sich innerhalb der Containergrenzen befinden.

Gilt für