What Are WinEvents?
Server applications and the operating system use WinEvents to notify clients when a change occurs in the system or in the user interface.
WinEvent support is a feature of the Windows operating system that provides:
- A simple way for clients to register for event notifications.
- A mechanism for injecting client code into servers.
- Routing of events from servers to interested clients.
- Automatic event generation for most HWND-based controls.
Event generation for HWND-based controls is especially important for server developers. The Microsoft Active Accessibility run-time provides IAccessible proxies for all standard UI elements. Similarly, the system automatically generates the appropriate WinEvents whenever it creates, destroys, moves, resizes, or performs any other action on an HWND-based control.
Some WinEvents, including general HWND events, are automatically supported by the system. Other types of WinEvents, such as state changes or selection events specific to a particular control, are supported by Microsoft Active Accessibility servers.
When an event occurs that affects the UI, servers can broadcast an event notification to all interested clients by calling the NotifyWinEvent function. The function call includes information that identifies the type of event that occurred, and the UI element to which the event applies. Clients can use this information to retrieve an IAccessible object for the UI element and collect more information.
For example, to notify clients that a control's name has changed, a server calls NotifyWinEvent and passes EVENT_OBJECT_NAMECHANGE in the event parameter. The system responds by determining which clients have registered to receive that particular event and calls their registered callback function. If no clients have registered for the event, the server's call to NotifyWinEvent is comparable to a "no operation" and the performance impact is negligible.
Servers call NotifyWinEvent to announce the event to the system after the event has occurred. They must never notify the system of an event before the event occurs.
To be notified of events, clients register callback hook functions by using SetWinEventHook. Clients set a single hook function for all possible events or multiple hook functions for discrete ranges of events. For more information, see Registering a Hook Function.
When Microsoft Active Accessibility is notified of an event, it calls any hook functions that were registered for that event, passing along the parameters from NotifyWinEvent.
Build date: 11/16/2013