Using the Default Logical PaletteThe easiest way to create a logical palette is with fg_defpal(), which creates a 256-color logical palette using Fastgraph's default colors. The fg_defpal() function has no parameters and returns a logical palette handle of type HPALETTE, or NULL (zero) if it could not create the logical palette. To activate the logical palette, pass the logical palette handle to fg_realize(). The following code, which typically appears in the program's WM_CREATE message handler after establishing a device context, illustrates this sequence:
C/C++:
Delphi:
Visual Basic:
Before a program exits, it should delete the logical palette with the Windows API function DeleteObject(). A good place to do this is in the program's WM_DESTROY message handler:
C/C++ and Delphi:
Visual Basic programs do not need to delete the logical palette, as Visual Basic handles this task automatically. As we just mentioned, fg_realize() activates a logical palette (this process is called realizing the logical palette, hence the function name). A program must of course realize a logical palette before using it, but it must also do this when its window becomes the active window. Programs should thus call fg_realize() in their WM_SETFOCUS message handler:
C/C++ and Delphi:
Visual Basic:
The default Fastgraph logical palette contains the Windows system colors in their default Windows positions (colors 0-9 and 246-255). The remaining 236 colors (colors 10 to 245) are a subset of the default colors used in DOS 256-color graphics modes, starting with the standard 16-color DOS color set (colors 10 to 25) and a coarse grayscale of increasing intensity (colors 26 to 29). The next 216 colors (30 to 245) contain three groups of 72 colors each, with the first group (30 to 101) at high intensity, the second group (102 to 173) at moderate intensity, and the third group (174 to 245) at low intensity. Each group consists of three ranges of decreasing saturation (increasing whiteness), with each range varying in hue from blue to red to green. This information is summarized in the following table.
|
 
copyright 2001 Ted Gruber Software, Inc.