Microsoft Windows CE 3.0  

Creating a Palette in Windowed Mode

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The following example illustrates how to create a DirectDraw palette in nonexclusive (windowed) mode. In order for your palette to work correctly, it is vital that you set up every one of the 256 entries in the PALETTEENTRYstructure that you submit to the IDirectDraw4::CreatePalettemethod.

LPDIRECTDRAW4 lpDD; // Assumed to be initialized
previously PALETTEENTRY pPaletteEntry[256]; int index; HRESULT
ddrval; LPDIRECTDRAWPALETTE2 lpDDPal; // First set up the Windows
static entries. for (index = 0; index < 10 ; index++) { // The
first 10 static entries: pPaletteEntry[index].peFlags =
PC_EXPLICIT; pPaletteEntry[index].peRed = index;
pPaletteEntry[index].peGreen = 0; pPaletteEntry[index].peBlue = 0;
// The last 10 static entries: pPaletteEntry[index+246].peFlags =
PC_EXPLICIT; pPaletteEntry[index+246].peRed = index+246;
pPaletteEntry[index+246].peGreen = 0;
pPaletteEntry[index+246].peBlue = 0; } // Now set up private
entries. In this example, the first 16 // available entries are
animated. for (index = 10; index < 26; index ++) {
pPaletteEntry[index].peFlags = PC_NOCOLLAPSE|PC_RESERVED;
pPaletteEntry[index].peRed = 255; pPaletteEntry[index].peGreen =
64; pPaletteEntry[index].peBlue = 32; } // Now set up the rest, the
nonanimated entries. for (; index < 246; index ++) // Index is
set up by previous for loop { pPaletteEntry[index].peFlags =
PC_NOCOLLAPSE; pPaletteEntry[index].peRed = 25;
pPaletteEntry[index].peGreen = 6; pPaletteEntry[index].peBlue = 63;
} // All 256 entries are filled. Create the palette. ddrval =
lpDD->CreatePalette(DDPCAPS_8BIT, pPaletteEntry,
&lpDDPal,NULL);


 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.