PJSoft Colour Popup Menu Component Demo Project

This project is provided with the PJSoft Colour Popup Menu component to demonstrate how to use the component.

Installing the Demo Project

The demo project is provided in the same zip file as the main component. Follow the installation instructions supplied with the zip file (pjcmenu.htm). Ensure that the component is installed before attempting to compile the demo project. The demo was created with Delphi 4.

Overview

The demo program contains a copy of the PJColourPopupMenu component and provides access to its properties via the user interface. When the program starts the component has its default values and the program appears as follows:

The window is divided into three main areas:

Altering the component properties

The values of several of the most important properties are displayed in the controls in the Component properties group box. They are:

Display style

Determines how the component displays the colours. Options are:

  • Text only -- displays only the names of the colours.
  • Colour only -- displays a palette of colours with no text.
  • Text and colour -- displays the names of colours and a swatch of colour to the left of the text.
  • Owner draw -- the user has to draw the menu items by handling the OnMeasureMenuItem and OnDrawMenuItem events. The demo program provides examples of how to do this -- it displays a menu with the names of colours centred on a background of the colour itself.

Test the various styles by chosing different ones from the Display style drop-down list.

Menu columns

Determines how many columns are used to display the menu. Options are:

  • 1 column (16 rows)
  • 2 columns (8 rows)
  • 4 columns (4 rows)
  • 8 columns (2 rows)
Check selected colour When this check box is checked the the curently selected colour is checked (or highlighted) in the menu.
Bitmap height Only used if the Display Style is Colour only. Determines the height of the bitmap used to represent the colour in the palette.
Bitmap width Only used if the Display Style is Colour only. Determines the width of the bitmap used to represent the colour in the palette.

Customising menu items

By handling the component's OnCreateMenuItem event you can change the colour menu items as required. This should be done with care since the component requires some of the menu item properties to have expected values in order to work properly. However, some properties can be modified safely -- look up the OnCreateMenuItem event component's help file for details.

The demo program has two modifications that can be applied to the test menu. They are:

Show colours as round

Checking this check box causes round colour swatches to appear next to the colour name when the Text and colour display style is used.

Display colour identifiers

Checking this check box replaces the default menu text (the names of colours) with the Delphi colour constant names. This happens for all display styles except Colour only.

A real life use of this facility would be to translate the colour names into another language.