IUIAutomation::AddPropertyChangedEventHandler 方法 (uiautomationclient.h)

注册处理属性更改事件和数组的方法。

注意 在实现事件处理程序之前,应熟悉了解线程问题中所述 的线程问题
 

语法

HRESULT AddPropertyChangedEventHandler(
  [in] IUIAutomationElement                     *element,
       TreeScope                                scope,
  [in] IUIAutomationCacheRequest                *cacheRequest,
  [in] IUIAutomationPropertyChangedEventHandler *handler,
  [in] SAFEARRAY                                *propertyArray
);

参数

[in] element

类型: IUIAutomationElement*

指向与事件处理程序关联的 UI 自动化 元素的指针。

scope

[in] cacheRequest

类型: IUIAutomationCacheRequest*

指向缓存请求的指针;如果不需要缓存,则为 NULL

[in] handler

类型: IUIAutomationPropertyChangedEventHandler*

指向处理事件的 对象的指针。

[in] propertyArray

类型: SAFEARRAY*

指向相关UI 自动化属性的指针。 有关属性 ID 的列表,请参阅 属性标识符

返回值

类型: HRESULT

如果该方法成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。

注解

元素指定的 UI 项可能不支持由 propertyArray 参数指定的属性。

UI 自动化客户端不应使用多个线程来添加或删除事件处理程序。 如果在同一客户端进程中添加或删除另一个事件处理程序,则会导致意外行为。

要求

要求
最低受支持的客户端 Windows 7、带 SP2 的 Windows Vista 和适用于 Windows Vista 的平台更新、带 SP3 的 Windows XP 和适用于 Windows Vista 的平台更新 [仅限桌面应用]
最低受支持的服务器 Windows Server 2008 R2、带 SP2 的 Windows Server 2008 和适用于 Windows Server 2008 的平台更新、带 SP2 的 Windows Server 2003 和适用于 Windows Server 2008 的平台更新 [仅限桌面应用]
目标平台 Windows
标头 uiautomationclient.h (包括 UIAutomation.h)

另请参阅

AddPropertyChangedEventHandlerNativeArray

使用安全数组的最佳做法

缓存UI 自动化属性和控件模式

概念性

IUIAutomation

引用

RemoveAllEventHandlers

RemovePropertyChangedEventHandler

订阅UI 自动化事件

了解线程问题