CPalette Class |
Description
The class responsible for creating and managing palette resources.
CPalette Members
Initialization and Assignment
Initialization and Assignment | |
CPalette | CPalette(); CPalette(HPALETTE hPalette);Constructs a CPaletteBrush object. |
static CPalette* FromHandle(HPALETTE hPalette);Returns the CPalette associated with the specified palette handle. If a CPalette object doesn't already exist, a temporary CPalette object is created. This temporary CPalette will be deleted sometime after the processing of the current message is complete.
operator HPALETTE() const;Allows a CPalette object to be used as a palette handle (HPALETTE).
int GetEntryCount() const;Retrieve the number of entries in the palette.
UINT GetNearestPaletteIndex (COLORREF crColor) const;Retrieves the index for the entry in the palette most closely matching a specified color value.
UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors) const;Retrieves a specified range of palette entries from the palette.
UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors);Sets RGB (red, green, blue) color values and flags in a range of entries in the palette.
void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors);Replaces entries in the palette.
HPALETTE CreateHalftonePalette(CDC* pDC);Creates a halftone palette for the specified device context (DC).
HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette);Creates a logical palette from the information in the specified LOGPALETTE structure.
Base class Members
For base class members, refer to the members of CGDIObject.
Remarks
CPalette objects can be used anywhere a a handle to a palette (HPALETTE) might be used. They can be substituted for the HPALETTE in any of the Windows API functions which use a HPALETTE as a function argument. The benefit of using a CPalette object is that it automatically deletes the brush when it is destroyed.
Refer to the Graphics Device Interface section of Using Win32++ for additional information on using this class.
Summary Information
Header file | gdi.h |
Win32/64 support | Yes |
WinCE support | Yes |