SandBar Toolbar Example

This example demonstrates how to implement .NET Add-in Extensibility for the Divelements Limited TD.SandBar.Toolbar control.

You can view the full source code of the final ToolBarSrv.cs class implementation in Understanding the ToolBarSrv.cs File.

A complete support set for the SandBar control, implemented both in C# and in Visual Basic, is located in <.NET_Add-in_Extensibility_SDK_installdir>\samples\WinFormsExtSample. You can use the files in this sample as an additional reference when performing this tutorial. For more information, see Using the .NET Add-in Extensibility Samples.

The Toolbar control appears as follows:

The Toolbar control is comprised of a variety of objects, such as:

  • ButtonItem objects, which represent buttons in the toolbar. ButtonItem objects contain images and no text. Each ButtonItem object has a unique tooltip.

  • DropDownMenuItem objects, which represent drop-down menus in the toolbar.

Both the ButtonItem object and the DropDownMenuItem object are derived from the ToolbarItemBase object.

When you implement a Custom Server for a custom control, you want UFT One to support recording and running the user's actions on the custom controls. When recording the test, your Custom Server listens to the control's events and handles the events to perform certain actions to add steps to the UFT One GUI test. When running the test, you simulate (replay) the same actions the user performed on that control.

For example, suppose you want to implement a user pressing a button on a custom toolbar. Before doing so, you must understand the toolbar control, its properties and methods, and understand how you can use them to implement the Custom Server.

Following are some of the SandBar ToolBar object's properties and events (methods are not visible in this image) as displayed in the Object Browser in Visual Studio:

As you can see in the image above, the ToolBar object has a property called Items that retrieves the collection of ToolbarItemBase objects assigned to the ToolBar control. You can also see that the ToolBar control has an event called ButtonClick. Your Custom Server can listen to the ButtonClick event to know when a button in the toolbar is clicked. However, this event does not indicate which specific button in the toolbar is clicked.

Now expand the ButtonItem object and review its properties, methods, and events:

As shown in the image above, the ButtonItem object is derived from the ToolbarItemBase object. You can see that the ToolbarItemBase object contains a ToolTipText property, but does not contain a Click event or method.

When you look at the custom toolbar object, the following possible implementation issues arise: