BackColor Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The BackColor property sets the background color of a message or a folder to be posted to the test log.

Declaration

LogAttributesObj.BackColor

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

Applies To

The property is applied to the following object:

Property Value

An integer value that denotes the desired background color. For a list of predefined color constants, see Working With Colors. To calculate a custom color value, you need to know the exact values of the red, green and blue components of that color and pass these values to an RGB function (see the example below).

Note: Intel CPUs use the little endian convention for data. That is, in fact, the color is stored as BGR in memory.

Example

The snippet below contains the definition of the RGB function (see above).

JavaScript, JScript

function CorrectRGBComponent(component)
{
  component = aqConvert.VarToInt(component);
  if (component < 0)
    component = 0;
  else
    if (component > 255)
      component = 255;
  return component;
}

function RGB(r, g, b)
{
  r = CorrectRGBComponent(r);
  g = CorrectRGBComponent(g);
  b = CorrectRGBComponent(b);
  return r | (g << 8) | (b << 16);
}

function Test()

{
  var Attr;
  Attr = Log.CreateNewAttributes();
  Attr.FontColor = RGB(192, 0, 0);
  Attr.BackColor = RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log.Message("My message", "", pmNormal, Attr);
}

Python

def CorrectRGBComponent(component):
  component = aqConvert.VarToInt(component)
  if component < 0:
    component = 0
  else:
    if component > 255:
      component = 255
  return component

def RGB(r, g, b):
  r = CorrectRGBComponent(r)
  g = CorrectRGBComponent(g)
  b = CorrectRGBComponent(b)
  return r | (g << 8) | (b << 16)

def Test():
  Attr = Log.CreateNewAttributes()
  Attr.FontColor = RGB(192, 0, 0)
  Attr.BackColor = RGB(255, 255, 0)
  # Passes the LogAttributes object to the Message function
  Log.Message("My message", "", pmNormal, Attr)

VBScript

Sub CorrectRGBComponent(ByRef component)
  component = aqConvert.VarToInt(component)
  If (component < 0) Then
    component = 0
  Else
    If (component > 255) Then
      component = 255
    End If
  End If
End Sub

Function RGB(r, g, b)
  Call CorrectRGBComponent(r)
  Call CorrectRGBComponent(g)
  Call CorrectRGBComponent(b)
  RGB = r + (g * 256) + (b * 65536)
End Function

Sub Test
  Set Attr = Log.CreateNewAttributes
  Attr.FontColor = RGB(192, 0, 0)
  Attr.BackColor = RGB(255, 255, 0)
  
  ' Passes the LogAttributes object to the Message function
  Log.Message "My message", "", pmNormal, Attr
End Sub

DelphiScript

procedure CorrectRGBComponent(var component);
begin
  component := aqConvert.VarToInt(component);
  if (component < 0) then
    component := 0
  else
    if (component > 255) then
      component := 255;
end;

function RGB(r, g, b) : integer;
begin
  CorrectRGBComponent(r);
  CorrectRGBComponent(g);
  CorrectRGBComponent(b);
  Result := r or (g shl 8) or (b shl 16);
end;

procedure Test;
var Attr : OleVariant;
begin
  Attr := Log.CreateNewAttributes;
  Attr.FontColor := RGB(192, 0, 0);
  Attr.BackColor := RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log.Message('My message', '', pmNormal, Attr);
end;

C++Script, C#Script

function CorrectRGBComponent(component)
{
  component = aqConvert["VarToInt"](component);
  if (component < 0)
    component = 0;
  else
    if (component > 255)
      component = 255;
  return component;
}

function RGB(r, g, b)
{
  r = CorrectRGBComponent(r);
  g = CorrectRGBComponent(g);
  b = CorrectRGBComponent(b);
  return r | (g << 8) | (b << 16);
}

function Test()
{
  var Attr;
  Attr = Log["CreateNewAttributes"]();
  Attr["FontColor"] = RGB(192, 0, 0);
  Attr["BackColor"] = RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log["Message"]("My message", "", pmNormal, Attr);
}

See Also

Test Results
Log Object
Working With Colors

Highlight search results