Class TForm1 (unit GrayForm)

Inherits from

TForm

Simple demonstration of Windows palettes. Copyright © 1998 Tempest Software, Inc. This program displays a gray scale gradation. It shows the basic principles of creating and using Windows palettes in Delphi.

Constructors



Functions

procedure FormCreate(Sender: TObject);

Always restore the old palette

procedure FormDestroy(Sender: TObject);

Free the palette.

procedure FormPaint(Sender: TObject);


procedure FormResize(Sender: TObject);

When the form changes size, make sure to repaint the entire window.

function GetPalette: HPalette;

Tell Delphi about the form's palette.

procedure WmEraseBkgnd(var Msg: TWmEraseBkgnd);

Handle of the gray scale palette

Tell Windows not to erase the background because the OnPaint handler will completely cover the form.


Properties

Events

Variables

NumShades : Integer;


Palette : HPalette;

Number of distinct gray shades


Constructors


Functions


procedure FormCreate(Sender: TObject);

Always restore the old palette


procedure FormDestroy(Sender: TObject);

Free the palette.


procedure FormPaint(Sender: TObject);


procedure FormResize(Sender: TObject);

When the form changes size, make sure to repaint the entire window. Otherwise, only the expanded part gets redrawn, and the gradation looks wrong.


function GetPalette: HPalette;

Tell Delphi about the form's palette. Delphi will automatically select and realize the palette when Windows requires it.


procedure WmEraseBkgnd(var Msg: TWmEraseBkgnd);

Handle of the gray scale palette

Tell Windows not to erase the background because the OnPaint handler will completely cover the form. This reduces the amount of flicker when repainting.


Properties


Events


Variables


NumShades : Integer;


Palette : HPalette;

Number of distinct gray shades