TransformPattern.Move(Double, Double) Methode

Definitie

Hiermee verplaatst u het besturingselement.

public:
 void Move(double x, double y);
public void Move(double x, double y);
member this.Move : double * double -> unit
Public Sub Move (x As Double, y As Double)

Parameters

x
Double

Absolute schermcoördinaten van de linkerkant van het besturingselement.

y
Double

Absolute schermcoördinaten van de bovenkant van het besturingselement.

Uitzonderingen

De CanMove eigenschap is onwaar.

Voorbeelden

In het volgende voorbeeld wordt een TransformPattern besturingspatroon verkregen uit een AutomationElement en vervolgens gebruikt om de 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.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

Opmerkingen

Een object kan niet zodanig worden verplaatst, aangepast of gedraaid dat de resulterende schermlocatie volledig buiten de coördinaten van de container valt en niet toegankelijk is voor het toetsenbord of de muis. Wanneer een venster op het hoogste niveau bijvoorbeeld volledig buiten het scherm wordt verplaatst of een onderliggend object buiten de grenzen van de viewport van de container wordt verplaatst. In deze gevallen wordt het object zo dicht mogelijk bij de aangevraagde schermcoördinaten geplaatst, waarbij de coördinaten boven of links worden overschreven om binnen de containergrenzen te vallen.

Van toepassing op