Handle Property

Applies to TestComplete 15.46, last modified on January 09, 2023

Description

The Picture.Handle property lets you obtain the handle of the image represented by the Picture object. A handle is an integer that Microsoft Windows uses to identify a window or another object, such as a font or bitmap. The handle of a window or object remains the same for the lifetime of the window (object). If you save the bitmap handle to a variable, you will be able to obtain the bitmap by its handle unless the bitmap is destroyed or recreated by that moment.

Declaration

PictureObj.Handle

Read-Only Property Integer
PictureObj An expression, variable or parameter that specifies a reference to a Picture object

Applies To

The property is applied to the following object:

Property Value

The integer number that denotes the handle of the image.

Example

The following example demonstrates how to post an image’s handle to the log and how to save an image to the clipboard.

JavaScript, JScript

function Test()
{
  var Pict = Utils.Picture;
  Pict.LoadFromFile("D:\\Data\\my_image.png");

  // Posts the handle of an image to the log
  Log.Message(Pict.Handle);

  // Saves the image to the clipboard
  Pict1.SaveToClipboard();

  // Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard);
}

Python

def Test():
  Pict = Utils.Picture
  Pict.LoadFromFile("D:\\Data\\my_image.png")
  # Posts the handle of an image to the log
  Log.Message(Pict.Handle)
  # Saves the image to the clipboard
  Pict.SaveToClipboard()
  # Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard)

VBScript

Sub Test
  Dim Pict
  Set Pict = Utils.Picture
  Call Pict.LoadFromFile("D:\Data\my_image.png")

  ' Posts the handle of an image to the log
  Call Log.Message(Pict.Handle)

  ' Saves the image to the clipboard
  Call Pict.SaveToClipboard

  ' Retrieves the data from the clipboard and posts it to the log
  Call Log.Picture(Sys.Clipboard)
End Sub

DelphiScript

procedure Test;
var Pict;
begin
  Pict := Utils.Picture;
  Pict.LoadFromFile('D:\Data\my_image.png');

  // Posts the handle of an image to the log
  Log.Message(Pict.Handle);

  // Saves the image to the clipboard
  Pict.SaveToClipboard;

  // Retrieves the data from the clipboard and posts it to the log
  Log.Picture(Sys.Clipboard);
end;

C++Script, C#Script

function Test()
{
  var Pict = Utils["Picture"];
  Pict["LoadFromFile"]("D:\\Data\\my_image.png");

  // Posts the handle of an image to the log
  Log["Message"](Pict["Handle"]);

  // Saves the image to the clipboard
  Pict["SaveToClipboard"]();

  // Retrieves the data from the clipboard and posts it to the log
  Log["Picture"](Sys["Clipboard"]);
}

See Also

Picture.Size

Highlight search results