Working With Owner-Drawn and Bitmap Menus in Desktop Windows Applications

Applies to TestComplete 15.64, last modified on May 16, 2024

In order for TestComplete to work with menu items, it needs a way to identify and specify them. TestComplete uses either item captions or indexes (position in the menu). Captions are more preferable than indexes, because they make scripts more readable and stable, whereas indexes are less easy to understand and, moreover, they may change during the run.

However, the application can use the OWNERDRAW (MFT_OWNERDRAW) style for its controls, including menus, which means that the application itself handles drawing the control, rather than the operating system. The controls drawn by the application are called owner-drawn. In general, owner-drawn menu items may have no caption and their contents can be arbitrary.

If a menu item is owner-drawn, TestComplete identifies it by its numerical adjective - index. This means that TestComplete records actions with owner-drawn menu items using their indexes.When writing test scripts or keyword tests manually, you should also specify such menu items by indexes (see Addressing Menu Items in Desktop Windows Applications). For example:


To determine whether a menu item is owner-drawn, you can explore the application in the Object Browser and check the IsOwnerdraw property for the desired item. If it is True, the menu item is owner-drawn; otherwise the item is ordinary.

Menus can also contain bitmap items, that is, items that display a bitmap instead of a text string. Such menu items have the BITMAP (MFT_BITMAP) style, and the IsBitmap property for these items returns True. Since these items have no caption, TestComplete also identifies them and records actions over them using indexes. You should also specify bitmap items by indexes when writing new tests.

To specify items of owner-drawn and bitmap menus by text, try using the appropriate approaches described in the Object Identification section. For other tips on dealing with non-standard controls, see Ways to Interact With Application Objects.

See Also

Working With Menus in Desktop Windows Applications
Testing Owner-Drawn Controls
Working With Third-Party Menus in Desktop Windows Applications
IsBitmap Property (MenuItem Objects)
IsOwnerdraw Property (MenuItem Objects)
Addressing Menu Items in Desktop Windows Applications

Highlight search results