CPalette Class

Encapsulates a Windows color palette.

class CPalette : public CGdiObject

Members

Public Constructors

Name

Description

CPalette::CPalette

Constructs a CPalette object with no attached Windows palette. You must initialize the CPalette object with one of the initialization member functions before it can be used.

Public Methods

Name

Description

CPalette::AnimatePalette

Replaces entries in the logical palette identified by the CPalette object. The application does not have to update its client area, because Windows maps the new entries into the system palette immediately.

CPalette::CreateHalftonePalette

Creates a halftone palette for the device context and attaches it to the CPalette object.

CPalette::CreatePalette

Creates a Windows color palette and attaches it to the CPalette object.

CPalette::FromHandle

Returns a pointer to a CPalette object when given a handle to a Windows palette object.

CPalette::GetEntryCount

Retrieves the number of palette entries in a logical palette.

CPalette::GetNearestPaletteIndex

Returns the index of the entry in the logical palette that most closely matches a color value.

CPalette::GetPaletteEntries

Retrieves a range of palette entries in a logical palette.

CPalette::ResizePalette

Changes the size of the logical palette specified by the CPalette object to the specified number of entries.

CPalette::SetPaletteEntries

Sets RGB color values and flags in a range of entries in a logical palette.

Public Operators

Name

Description

CPalette::operator HPALETTE

Returns the HPALETTE attached to the CPalette.

Remarks

A palette provides an interface between an application and a color output device (such as a display device). The interface allows the application to take full advantage of the color capabilities of the output device without severely interfering with the colors displayed by other applications. Windows uses the application's logical palette (a list of needed colors) and the system palette (which defines available colors) to determine the colors used.

A CPalette object provides member functions for manipulating the palette referred to by the object. Construct a CPalette object and use its member functions to create the actual palette, a graphics device interface (GDI) object, and to manipulate its entries and other properties.

For more information on using CPalette, see Graphic Objects.

Inheritance Hierarchy

CObject

CGdiObject

CPalette

Requirements

Header: afxwin.h

See Also

Reference

CGdiObject Class

Hierarchy Chart

CPalette::GetPaletteEntries

CPalette::SetPaletteEntries

Concepts

MFC Sample DIBLOOK