Class TMovingGradient (unit Moving)

Inherits from

TGradient

Demostration of palettes and animation in a Delphi component. Copyright © 1998 Tempest Software, Inc. The TMovingGradient component displays a color gradient, with a user-specified starting and ending color, and number of color steps between them. When Enabled, the gradient continually rotates, which has the effect of moving sideways. Set Enabled to False to stop the animation effect. Palette animation works only on displays that use a palette, namely, 256-color video adapters. One possible use for this "non-progress" bar is to show that a process is running but you don't know when it will finish.

Constructors


constructor Create(Owner: TComponent);

Create and initialize the control.


Functions

procedure Animate(Sender: TObject);

Animate the control by shifting the colors and then telling Windows to use the new colors.

procedure GetColor(var Red, Green, Blue: Byte; Index: Integer);

Compute a color for the gradient.

function MakePalette: HPalette;

Make a gradient palette and return the palette handle.

procedure ShiftColors;

Shift the colors to animate the palette.

procedure CmEnabledChanged(var Msg: TWmNoParams);

Propagate changes to the Enabled property to the timer, but at design time, leave the timer disabled.

function GetInterval: Cardinal;

Get the interval from the timer.

procedure SetInterval(Value: Cardinal);

Propagate changes to the update interval to the timer.

Properties

property ColorBottom :


property Enabled :


property Height :


property Interval : Cardinal


Events

Variables

fTimer : TTimer;

Timer for animating the palette


Constructors


constructor Create(Owner: TComponent);

Create and initialize the control. Start with 64 steps because most palette devices use 18 bits per pixel, which means 6 bits per color, or 64 distinct colors. The colors blue and white look nice, but feel free to change them to whatever you find more aesthetic. Ditto for the default size.


Functions


procedure Animate(Sender: TObject);

Animate the control by shifting the colors and then telling Windows to use the new colors.


procedure GetColor(var Red, Green, Blue: Byte; Index: Integer);

Compute a color for the gradient.


function MakePalette: HPalette;

Make a gradient palette and return the palette handle. Call this once when initializing the control. If the user changes the number of steps or the colors, recreate the palette with the new information.


procedure ShiftColors;

Shift the colors to animate the palette. Just rotate all the colors in the palette by one step.


procedure CmEnabledChanged(var Msg: TWmNoParams);

Propagate changes to the Enabled property to the timer, but at design time, leave the timer disabled.


function GetInterval: Cardinal;

Get the interval from the timer.


procedure SetInterval(Value: Cardinal);

Propagate changes to the update interval to the timer.


Properties


property ColorBottom :


property Enabled :


property Height :


property Interval : Cardinal


Events


Variables


fTimer : TTimer;

Timer for animating the palette