WindowPattern.WindowPatternInformation.IsTopmost プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
AutomationElement が z オーダーの最上位の要素かどうかを指定する値を取得します。
public:
property bool IsTopmost { bool get(); };
public bool IsTopmost { get; }
member this.IsTopmost : bool
Public ReadOnly Property IsTopmost As Boolean
プロパティ値
AutomationElement が最上位の場合は true
、それ以外は false
。
例
次の例では、 AutomationPropertyChangedEventHandler の への変更 IsTopmostProperty をリッスンするように が AutomationElement定義されています。
///--------------------------------------------------------------------
/// <summary>
/// Register for automation property change events of interest.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
///--------------------------------------------------------------------
private void RegisterForPropertyChangedEvents(
AutomationElement targetControl)
{
AutomationPropertyChangedEventHandler propertyChangeListener =
new AutomationPropertyChangedEventHandler(
OnTopmostPropertyChange);
Automation.AddAutomationPropertyChangedEventHandler(
targetControl,
TreeScope.Element,
propertyChangeListener,
WindowPattern.IsTopmostProperty);
}
'''--------------------------------------------------------------------
''' <summary>
''' Register for automation property change events of interest.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
'''--------------------------------------------------------------------
Private Sub RegisterForPropertyChangedEvents( _
ByVal targetControl As AutomationElement)
Dim propertyChangeListener As AutomationPropertyChangedEventHandler = _
New AutomationPropertyChangedEventHandler(AddressOf _
OnTopmostPropertyChange)
Automation.AddAutomationPropertyChangedEventHandler( _
targetControl, _
TreeScope.Element, _
propertyChangeListener, _
WindowPattern.IsTopmostProperty)
End Sub
///--------------------------------------------------------------------
/// <summary>
/// Register for automation property change events of interest.
/// </summary>
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
///--------------------------------------------------------------------
private void OnTopmostPropertyChange(object src, AutomationPropertyChangedEventArgs e)
{
// Make sure the element still exists. Elements such as tooltips
// can disappear before the event is processed.
AutomationElement sourceElement;
try
{
sourceElement = src as AutomationElement;
}
catch (ElementNotAvailableException)
{
return;
}
// Get a WindowPattern from the source of the event.
WindowPattern windowPattern = GetWindowPattern(sourceElement);
if (windowPattern.Current.IsTopmost)
{
//TODO: event handling
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Register for automation property change events of interest.
''' </summary>
''' <param name="src">Object that raised the event.</param>
''' <param name="e">Event arguments.</param>
'''--------------------------------------------------------------------
Private Sub OnTopmostPropertyChange(ByVal src As Object, _
ByVal e As AutomationPropertyChangedEventArgs)
' Make sure the element still exists. Elements such as tooltips
' can disappear before the event is processed.
Dim sourceElement As AutomationElement
Try
sourceElement = DirectCast(src, AutomationElement)
Catch exc As ElementNotAvailableException
Return
End Try
' Get a WindowPattern from the source of the event.
Dim windowPattern As WindowPattern = GetWindowPattern(sourceElement)
If (WindowPattern.Current.IsTopmost) Then
'TODO: event handling
End If
End Sub
適用対象
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET