forked from eclipse-threadx/guix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccessibilty_props_service.cpp
133 lines (119 loc) · 3.55 KB
/
accessibilty_props_service.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "resource.h"
#include <initguid.h>
#include "objbase.h"
#include "uiautomation.h"
#include "accessibility_props_service.h"
static IAccPropServices* _pAccPropServices = NULL;
// Create accessibility property service
void CreateAccPropService()
{
CoCreateInstance(
CLSID_AccPropServices,
nullptr,
CLSCTX_INPROC,
IID_PPV_ARGS(&_pAccPropServices));
}
// Release accessibility property service
void ReleaseAccPropService()
{
if (_pAccPropServices != nullptr)
{
_pAccPropServices->Release();
_pAccPropServices = NULL;
}
}
// Run when the UI is created.
void SetControlAccessibleName(HWND ctr_handle, LPCWSTR name)
{
if (_pAccPropServices != nullptr)
{
// Now set the name on the edit control. This gets exposed through UIA as the
// element's Name property.
_pAccPropServices->SetHwndPropStr(
ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
Name_Property_GUID,
name);
}
}
// Annotate role property
void SetControlAccessibleRole(HWND ctr_handle, LONG role)
{
if (_pAccPropServices != nullptr)
{
// Annotating the Role of this object to be STATICTEXT
VARIANT var;
var.vt = VT_I4;
var.lVal = role;
_pAccPropServices->SetHwndProp(ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
PROPID_ACC_ROLE,
var);
}
}
// Set accessible help string for a control
void SetAccessibleHelpString(HWND ctr_handle, LPCWSTR help_string)
{
if (_pAccPropServices != nullptr)
{
// Expose the help string through UIA as the element's HelpText property.
_pAccPropServices->SetHwndPropStr(
ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
PROPID_ACC_HELP,
help_string);
}
}
// Set a lable to be a LiveRegion
void SetLiveRegion(HWND ctr_handle)
{
if (_pAccPropServices != nullptr)
{
// Set up the status label to be an assertive LiveRegion. The assertive property
// is used to request that the screen reader announces the update immediately.
// And alternative setting of polite requests that the screen reader completes
// any in-progress announcement before announcing the LiveRegion update.
VARIANT var;
var.vt = VT_I4;
var.lVal = Assertive;
_pAccPropServices->SetHwndProp(
ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
LiveSetting_Property_GUID,
var);
}
}
// Set accessible full description for a control
void SetAccessibleFullDescription(HWND ctr_handle, LPCWSTR string)
{
if (_pAccPropServices != nullptr)
{
// Expose a localized string which can contain extended description text for an element.
// FullDescription can contain a more complete description of an element than maybe
// appropriate for the element name.
_pAccPropServices->SetHwndPropStr(
ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
FullDescription_Property_GUID,
string);
}
}
// Set accessible description string for a control
void SetAccessibleDescription(HWND ctr_handle, LPCWSTR help_string)
{
if (_pAccPropServices != nullptr)
{
// Expose the descriotion through UIA as the element's Description property.
_pAccPropServices->SetHwndPropStr(
ctr_handle,
OBJID_CLIENT,
CHILDID_SELF,
PROPID_ACC_DESCRIPTION,
help_string);
}
}