Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.84 KB

File metadata and controls

50 lines (35 loc) · 1.84 KB

ConsoleColors property

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Applies to: ~>3.0

property ConsoleColors: TPJConsoleColors;

Description

This property determines the foreground and background colours of a console window. It is of type TPJConsoleColors, which is a record with fields for both colours. Colours must be from the 16 basic system colours and are specified using the TPJConsoleColor enumeration.

Default values are ccWhite for the foreground colour and ccBlack for the background.

Remarks

If a console application shares a console this property has no effect. See UseNewConsole for more information about shared consoles.

The individual fields of the property are read-only so the property must be set by first creating a TPJConsoleColors record containing the required foreground and background colours and then assigning the record to the property. For example:

var
  Colors: TPJConsoleColors;
  App: TPJConsoleApp;
begin
  // assume App contains a valid TPJConsoleApp instance
  Colors.Foreground := ccYellow;
  Colors.Background := ccNavy;
  App.ConsoleColors := Colors;
end;

The MakeConsoleColors routine has been provided to make this process easier. The following code has the same effect as the above:

var
  App: TPJConsoleApp;
begin
  // assume App contains a valid TPJConsoleApp instance
  App.ConsoleColors := MakeConsoleColors(ccYellow, ccNavy);
end;

The property is public in TPJConsoleApp and protected in TPJCustomConsoleApp.