If a user is using a screen reader (e.g. Microsoft Narrator), and their focus enters a text box:
All they hear is:
Editing text
Meanwhile in accessible applications,
- such as Microsoft File Explorer
- Microsoft Word
- Microsoft Excel
- Microsoft Outlook
the accessibility system is able to get the control's "Accessible Name":
Batch separator. Editing text
This works though the window implementing the IAccessible interface. It obtains a window's implementation of IAccessible by sending the hWnd the WM_GETOBJECT message. Applications never send this message though:
Sent by both Microsoft Active Accessibility and Microsoft UI Automation to obtain information about an accessible object contained in a server application.
Applications never send this message directly. Microsoft Active Accessibility sends this message in response to calls to AccessibleObjectFromPoint, AccessibleObjectFromEvent, or AccessibleObjectFromWindow.
But we can handle the message, and return an IAccessible interface to the caller:
case Message.Msg of
WM_GETOBJECT:
begin
if DWORD(Message.LParam) = OBJID_CLIENT then
Message.Result := LResultFromObject(IAccessible, Message.WParam, FAccessible);
end;
end;
In the .NET world, their wrapper around an Edit control, exposes a way to set the accessible name of an TextBox using the Control.AccessibleName property:
Control.AccessibleName Property
Gets or sets the name of the control used by accessibility client applications.
public string AccessibleName { get; set; }
I don't know how the underlying Microsoft Edit control exposes accessibility features. I couldn't find any reference to IAccessible in the VCL except for TCustomActionMenuBar.
How does the VCL expose accessibility features?
How do i set the Accessible Name associated with a TEdit control?
How do i set the Accessible Name associated with an Edit control?
Bonus Chatter
The name of an accessible item is returned through the read-only IAccessible.accName property.
Property Access Type Description
-------- ----------- ----------------------------------------------------------
accName Read-only The name of the object. All objects support this property.
See get_accName.
IAccessible
interface by yourself (the Accessible Name you return in itsGet_accName
method). – Knisley