Aracılığıyla paylaş


WindowPattern.Close Yöntem

Tanım

Geçerli pencereyi kapatmayı dener.

public:
 void Close();
public void Close ();
member this.Close : unit -> unit
Public Sub Close ()

Özel durumlar

Denetim istenen eylemi gerçekleştiremiyor.

Denetim artık kullanılabilir olmadığında.

Örnekler

Aşağıdaki örnekte, 'AutomationElementden bir WindowPattern denetim deseni alınır ve daha sonra kapatmak AutomationElementiçin kullanılır.

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

    try
    {
        windowPattern =
            targetControl.GetCurrentPattern(WindowPattern.Pattern)
            as WindowPattern;
    }
    catch (InvalidOperationException)
    {
        // object doesn't support the WindowPattern control pattern
        return null;
    }
    // Make sure the element is usable.
    if (false == windowPattern.WaitForInputIdle(10000))
    {
        // Object not responding in a timely manner
        return null;
    }
    return windowPattern;
}
'''------------------------------------------------------------------------
''' <summary>
''' Obtains a WindowPattern control pattern from an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A WindowPattern object.
''' </returns>
'''------------------------------------------------------------------------
Private Function GetWindowPattern(ByVal targetControl As AutomationElement) As WindowPattern
    Dim windowPattern As WindowPattern = Nothing

    Try
        windowPattern = DirectCast( _
        targetControl.GetCurrentPattern(windowPattern.Pattern), _
        WindowPattern)
    Catch
        ' object doesn't support the WindowPattern control pattern
        Return Nothing
    End Try
    ' Make sure the element is usable.
    If False = windowPattern.WaitForInputIdle(10000) Then
        ' Object not responding in a timely manner
        Return Nothing
    End If
    Return windowPattern
End Function 'GetWindowPattern
///--------------------------------------------------------------------
/// <summary>
/// Calls the WindowPattern.Close() method for an associated 
/// automation element.
/// </summary>
/// <param name="windowPattern">
/// The WindowPattern control pattern obtained from
/// an automation element.
/// </param>
///--------------------------------------------------------------------
private void CloseWindow(WindowPattern windowPattern)
{
    try
    {
        windowPattern.Close();
    }
    catch (InvalidOperationException)
    {
        // object is not able to perform the requested action
        return;
    }
}
'''------------------------------------------------------------------------
''' <summary>
''' Calls the WindowPattern.Close() method for an associated 
''' automation element.
''' </summary>
''' <param name="windowPattern">
''' The WindowPattern control pattern obtained from
''' an automation element.
''' </param>
'''------------------------------------------------------------------------
Private Sub CloseWindow(ByVal windowPattern As WindowPattern)
    Try
        windowPattern.Close()
    Catch
        ' object is not able to perform the requested action
        Return
    End Try

End Sub

Açıklamalar

Bölünmüş bölme denetiminde çağrıldığında, bu yöntem bölmeyi kapatır ve ilişkili bölmeyi kaldırır. Bu yöntem, uygulamaya bağlı olarak diğer tüm bölmeleri de kapatabilir.

Şunlara uygulanır