Width Property

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The Size.Width property lets you get and set the width of a rectangular area.

Declaration

SizeObj.Width

Read-Write Property Integer
SizeObj An expression, variable or parameter that specifies a reference to a Size object

Applies To

The property is applied to the following object:

Property Value

The width (in pixels) of the rectangular area specified by the given Size object.

Example

The code below demonstrates how you can load an image from a file and then retrieve the width and height of the image.

JavaScript, JScript

function Test1()
{
  // Creates a new empty Picture object
  Pict = Utils.Picture;

  // Loads the image from a file and posts it to the log
  Pict.LoadFromFile("D:\\Data\\my_image.png");
  Log.Picture (Pict, "My image");

  // Posts the image’s size to the log
  Log.Message (Pict.Size.Width);
  Log.Message (Pict.Size.Height);
}

Python

def Test1():
  # Creates a new empty Picture object
  Pict = Utils.Picture

  # Loads the image from a file and posts it to the log
  Pict.LoadFromFile("D:\\Data\\my_image.png")
  Log.Picture(Pict, "My image")

  # Posts the image's size to the log
  Log.Message(str(Pict.Size.Width))
  Log.Message(str(Pict.Size.Height))

VBScript

Sub Test1
  ' Creates a new empty Picture object
  Set Pict = Utils.Picture

  ' Loads the image from a file and posts it to the log
  Call Pict.LoadFromFile("D:\Data\my_image.png")
  Log.Picture Pict, "My image"

  ' Posts the image’s size to the log
  Log.Message Pict.Size.Width
  Log.Message Pict.Size.Height
End Sub

DelphiScript

procedure Test1;
begin
  // Creates a new empty Picture object
  Pict := Utils.Picture;

  // Loads the image from a file and posts it to the log
  Pict.LoadFromFile('D:\Data\my_image.png');
  Log.Picture (Pict, 'My image');

  // Posts the image’s size to the log
  Log.Message (Pict.Size.Width);
  Log.Message (Pict.Size.Height);
end;

C++Script, C#Script

function Test1()
{
  // Creates a new empty Picture object
  Pict = Utils["Picture"];

  // Loads the image from a file and posts it to the log
  Pict["LoadFromFile"]("D:\\Data\\my_image.png");
  Log["Picture"](Pict, "My image");

  // Posts the image’s size to the log
  Log["Message"](Pict.Size.Width);
  Log["Message"](Pict.Size.Height);
}

See Also

Size.Height

Highlight search results