语言

AutomationElement.NativeWindowHandleProperty 字段

定义

标识 NativeWindowHandle 属性。

public: static initonly System::Windows::Automation::AutomationProperty ^ NativeWindowHandleProperty;
public static readonly System.Windows.Automation.AutomationProperty NativeWindowHandleProperty;
 staticval mutable NativeWindowHandleProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly NativeWindowHandleProperty As AutomationProperty 

字段值

示例

以下示例检索属性的当前值。 如果元素不提供默认值,则返回默认值。

int nativeHandle = (int)
    autoElement.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty);
Dim nativeHandle As Integer = _
    CInt(autoElement.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty))

下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则返回而不是默认值。

int nativeHandle1;
object nativeHandleNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty, true);
if (nativeHandleNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
    nativeHandle1 = (int)nativeHandleNoDefault;
}
Dim nativeHandle1 As Integer
Dim nativeHandleNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty, True)
If nativeHandleNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    nativeHandle1 = CInt(nativeHandleNoDefault)
End If

注解

此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 AutomationElementIdentifiers 中的等效标识符。

也可以从 Current 或 Cached 属性中检索此属性。

属性的返回值为类型 Int32。 属性的默认值为 0。

适用于

另请参阅