TdxAutomationElementSettings.OnInitializeProperties Event
Allows you to initialize UIA node properties manually.
Declaration
property OnInitializeProperties: TdxInitializeAutomationPropertiesEvent read; write;
Remarks
You can handle the OnInitializeProperties
event to initialize individual UI automation node properties manually.
Event Occurrence
The OnInitializeProperties
event occurs in response to the first UIA node property request. If any property value of the same node changes after initialization, the OnInitializeProperties
event occurs again in response to the next UIA node property request.
Event Parameters
The following parameters are available within an OnInitializeProperties
event handler:
ASender
- Provides access to the control/UI element that raised the
OnInitializeProperties
event. AProperties
Provides access to initialized UIA node properties.
You can use
AProperties
.Name andAProperties
.FullDescription properties to modify corresponding UIA node properties for the parent control (ASender
).
Refer to the TdxInitializeAutomationPropertiesEvent procedural type description for detailed information on all parameters accessible within an OnInitializeProperties
event handler.
Code Examples
Initialize UIA Node Properties for Editors
The following code example initializes Name and FullDescription UIA node names for an existing single-line text editor (TcxTextEdit):
uses
dxUIAClasses, // Declares all UI Automation classes
cxEdit, // Declares base editor classes and auxiliary types
cxTextEdit; // Declares the TcxTextEdit class
// ...
procedure TMyForm.cxTextEdit1PropertiesAutomationCalculateProperty(
ASender: TObject; AProperties: TdxAutomationProperties);
begin
AProperties.Name.Value := 'Task Description';
AProperties.FullDescription.Value := 'Non-Editable';
end;
Calculate Only UIA Node Names for Editors
The code example in this section demonstrates an OnInitializeProperties
event handler that disables automatic calculation for UIA node properties and enables calculation only for the Name UIA property. The form’s OnCreate event handler assigns the same OnInitializeProperties
event handler to TcxTextEdit, TcxButtonEdit, and TcxCheckBox editors.
uses
dxUIAClasses, // Declares all UI Automation classes
cxEdit, // Declares base editor classes and auxiliary types
cxTextEdit, // Declares the TcxTextEdit class
cxCheckBox, // Declares the TcxCheckBox class
cxButtonEdit; // Declares the TcxButtonEdit class
// ...
procedure TMyForm.InitializeAutomationProperties(
ASender: TObject; AProperties: TdxAutomationProperties);
begin
if dxUIACalculateAllProperties then
dxUIACalculateAllProperties := False; // Disables automatic UIA node property calculation
AProperties.Name.Calculated := True; // Enables calculation for the initialized Name UIA property
end;
procedure TMyForm.FormCreate(Sender: TObject);
begin
cxTextEdit1.Properties.Automation.OnInitializeProperties := InitializeAutomationProperties;
cxCheckBox1.Properties.Automation.OnInitializeProperties := InitializeAutomationProperties;
cxButtonEdit1.Properties.Automation.OnInitializeProperties := InitializeAutomationProperties;
end;