IsBitmap Property (MenuItem Objects)

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

If the application uses a bitmap rather than text to display the menu item, IsBitmap returns True. Otherwise, it returns False. As “bitmap” items may hold no text, you should use their indexes when working with them.

Declaration

TestObj.IsBitmap

Read-Only Property Boolean
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following object:

View Mode

To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Property Value

True, if the application uses a bitmap rather than text to display the menu item; Otherwise - False.

Example

The following code snippet iterates through the items of Windows Notepad’s File menu and determines whether the application uses bitmaps or text to display the items.

JavaScript, JScript

function MenuItemSample()
{
  // Obtains the Windows Notepad main menu
  var MainMenu = Sys.Process("Notepad").Window("Notepad", "*").MainMenu;
  // Obtains the File menu
  var FileMenu = MainMenu.Items("File").SubMenu;

  // Iterates through the items in the File menu
  // And checks whether the application uses a bitmap or text to display the items
  for (var i = 0; i < FileMenu.Count; i++)
  {
    var Item = FileMenu.Items(i);
    if (Item.IsBitmap)
      Log.Message("The menu item with the " + aqConvert.IntToStr(Item.Position) +
                  " index is a bitmap");

    else
    {
      if (! Item.IsSeparator)
        Log.Message("The menu item with the " + aqConvert.IntToStr(Item.Position) +
                    " index is displayed with the text: " + Item.Caption);
    }

  }
}

Python

def MenuItemSample():
  # Obtains the Windows Notepad main menu
  MainMenu = Sys.Process("Notepad").Window("Notepad", "*").MainMenu
  # Obtains the File menu
  FileMenu = MainMenu.Items["File"].SubMenu

  # Iterates through the items in the File menu
  # And checks whether the application uses a bitmap or text to display the items
  for i in range (0, FileMenu.Count):
    Item = FileMenu.Items[i]
    if (Item.IsBitmap):
      Log.Message("The menu item with the " + aqConvert.IntToStr(Item.Position) +\
                  " index is a bitmap")

    else:
      if (not Item.IsSeparator):
        Log.Message("The menu item with the " + aqConvert.IntToStr(Item.Position) +\
                    " index is displayed with the text: " + Item.Caption)

VBScript

Sub MenuItemSample
  ' Obtains the Windows Notepad main menu
  Set MainMenu = Sys.Process("Notepad").Window("Notepad", "*").MainMenu
  ' Obtains the File menu
  Set FileMenu = MainMenu.Items("File").SubMenu

  ' Iterates through the items in the File menu
  ' And checks whether the application uses a bitmap or text to display the items
  For i = 0 To FileMenu.Count - 1

    Set Item = Filemenu.Items(i)
    If Item.IsBitmap Then
      Log.Message "The menu item with the " & aqConvert.IntToStr(Item.Position) & _
                  " index is a bitmap"

    Else
      If Not Item.IsSeparator Then
        Log.Message "The menu item with the " & aqConvert.IntToStr(Item.Position) & _
                    " index is displayed with the text: " & Item.Caption
      End If
    End If

  Next
End Sub

DelphiScript

procedure MenuItemSample();
var
  MainMenu, FileMenu, Item : OleVariant;
  i : integer;
begin
  // Obtains the Windows Notepad main menu
  MainMenu := Sys.Process('Notepad').Window('Notepad', '*').MainMenu;
  // Obtains the File menu
  FileMenu := MainMenu.Items('File').SubMenu;

  // Iterates through the items in the File menu
  // And checks whether the application uses a bitmap or text to display the items
  for i := 0 to FileMenu.Count - 1 do
  begin
    Item := FileMenu.Items[i];
    if Item.IsBitmap then
      Log.Message('The menu item with the ' + aqConvert.IntToStr(Item.Position) +
                  ' index is a bitmap')

    else
    begin
      if not Item.IsSeparator then
        Log.Message('The menu item with the ' + aqConvert.IntToStr(Item.Position) +
                    ' index is displayed with the text: ' + Item.Caption);
    end;

  end;
end;

C++Script, C#Script

function MenuItemSample()
{
  // Obtains the Windows Notepad main menu
  var MainMenu = Sys["Process"]("Notepad")["Window"]("Notepad", "*")["MainMenu"];
  // Obtains the File menu
  var FileMenu = MainMenu["Items"]("File")["SubMenu"];

  // Iterates through the items in the File menu
  // And checks whether the application uses a bitmap or text to display the items
  for (var i = 0; i < FileMenu["Count"]; i++)
  {
    var Item = FileMenu["Items"](i);
    if (Item["IsBitmap"])
      Log.Message("The menu item with the " + aqConvert["IntToStr"](Item["Position"]) +
                  " index is a bitmap");

    else
    {
      if (! Item["IsSeparator"])
        Log["Message"]("The menu item with the " + aqConvert["IntToStr"](Item["Position"]) +
                    " index is displayed with the text: " + Item["Caption"]);
    }

  }
}

See Also

Working With Owner-Drawn and Bitmap Menus in Desktop Windows Applications
IsOwnerdraw Property (MenuItem Objects)
IsRadioCheck Property (MenuItem Objects)
IsSeparator Property (MenuItem Objects)

Highlight search results