MFCustomPalette Component Help


Overview  Installation   Properties  Methods  Events   Terms of Use and Registration


 

Overview
TCustomPalette is actually a TPanel descendant, but it mimics the functionality of the TColorGrid component supplied as a sample VCL with Delphi. It also has a number of additional features.

Like TColrGrid there are 16 color cells (which the programmer can choose to display in 2, 4 or 8 columns).

Unlike TColorGrid, the programmer (and by extension the User) can change the colors of each individual cell to create custom palettes for special color selection needs.

The colors in the grid can also be saved to or restored from a file by calling the appropriate method.

 

Installation

Put the MFCustomPalette.pas, MFCustomPalette.res and MFCustomPalette.dcr files in a directory in your library path then select MFCustomPalette.pas using the Component/Install Component Menu Selection in the IDE.

 

Properties
Columns This property takes a TColumns type which specifies whether the color grid is shown in 2, 4 or 8 columns. It can have one of the following values:

colomns2, columns4, or columns8

 

Methods
SetStandardColors When a TCustomPalette component is first created, the colors of the individual cells correspond to the 16 colors in the standard palette (ie: clBlack to clWhite). Calling this method restores those colors after they have been changed by the SetCellColor method.
SetCellColor This method changes a cell color and takes the form:

SetCellColor(index, color)

index is an integer representing the number of the cell you wish to change.

color is a TColor value you wish the cell to contain.

Note: the cells are numbered 0 to 15 where o is always the top left cell, and 15 the bottom right.

GetCellColor This method retrieves the color of a specified cell as follows:

GetCellColor(index) : color;

index is an integer representing the number of the cell whose color you wish to retrieve.

color is a TColor value.

SaveTo File This method saves the values of the colors in each cell to a file in Inifile format. The programmer can specify any filename. The method has the following form:

SaveToFile( name)

name is a string representing the filename.

LoadFromFile This method sets the color grid to those values stored in a file saved by the SaveToFile method. If any other type of file is specified the method fails.

It has the following form:

SaveToFile( name)

name is a string representing the filename.

 

Events
OnCellClick When the user clicks the color grid this event is fired, supplying the application with the index of the cell clicked, the mouse button used, and the color of the cell in question.

Example:

OnCellClick( index : integer; Button : TMouseButton; color : TColor);

OnResize Standard OnResize event.

 

Terms of Use and Registration
This component is shareware not freeware. If you decide to use it after evaluation, you must register it. Upon registration you may use the component freely in any freeware or shareware applications you create and distribute.

Use of the component in a commercial application is prohibited without prior written permission from the author. Any additional fee or requirements will be determined based on the nature of the application.

This component is provided to you with the full source code 'On Trust'. If you decide to use it please do the honorable thing and register.

Please visit MicroFrame's website for instructions concerning registration