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,
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?
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.
How does the VCL expose accessibility features?
It doesn't, at all.
If you want this feature, you have to manually implement everything related to IAccessible
yourself in your own code, and then subclass your VCL controls to respond to the WM_GETOBJECT
message, just like you showed in your question.
For example:
Creating Accessible UI components in Delphi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With