Understanding Infragistic Controls: Toolbar Control
Infragistic toolbars may be placed at the top, bottom, left, or right of a form. The best way to find the toolbar is by using TestComplete's Object Browser. Depending on where exactly your toolbar is placed it will have different suffixes. For example, top toolbar will have suffix "_Top".
After finding the toolbar you can investigate it's properties.
The Infragistic toolbar is not a simple toolbar, but a set of several toolbars, which is visible as a "Toolbars_Dock_Area" with a corresponding suffix ("Top", "Bottom", etc.). It's ToolbarsManager property contains all of the data needed to perform a button click.
Let's imagine that there is only one toolbar placed in one toolbars container. In this case it will have the index number 0. To use this toolbar, you need to use the ToolbarsManager.Toolbars.Item property.
Each Toolbars property has a child Tools property. The Tools property contains all of the buttons' information. To get the information about each button you need to check the corresponding Item property of the toolbar with the index number 0.
To get the coordinates used to perform a click, you need to use the Tool's Bounds property. Please note that the coordinates are desktop related. There are two ways to click on the button of the toolbar:
- Get the absolute coordinates and perform a mouse click on the Desktop using the Desktop's MouseDown() and MouseUp() methods.
- Get the absolute coordinates of the button and then subtract the toolbar's coordinates from the button coordinates. I prefer to use this solution because the first one can perform a button click even if there is an overlapping window without any error messages.
Here is a simple example:
In some cases toolbar buttons can be invisible or disabled and this can cause a problem. So, you should check both of these properties before getting the button's coordinates.
Below is an example that shows you how to check the properties:
Also, there could be more than one toolbar in a toolbar container as noted in the beginning. This can also cause a problem, so, we should modify the function to search for the button in all toolbars:
I recommend replacing the following string:
if(oTool.CaptionResolved.OleValue == sButton)
With this one:
This allows you to use only a part of the button caption and not the full button caption. For example, "Save" instead of "Save Record".
Below is an example of a script that uses the created function:
You can download the sample application from the link below:
InfragisticToolbar.zip (zip, 5 Kb)