WindowPattern.Close 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 창을 닫으려고 시도합니다.
public:
void Close();
public void Close ();
member this.Close : unit -> unit
Public Sub Close ()
예외
컨트롤이 요청한 작업을 수행할 수 없습니다.
컨트롤을 더 이상 사용할 수 없을 때입니다.
예제
다음 예제에서는 WindowPattern 컨트롤 패턴에서 가져온는 AutomationElement 을 사용 하 여 닫습니다는 AutomationElement합니다.
///--------------------------------------------------------------------
/// <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
설명
분할 창 컨트롤에서 호출 되 면이 메서드를 창을 닫으려면 연결된 된 분할을 제거 합니다. 이 메서드 구현에 따라 다른 모든 창의 닫을 수도 있습니다.