Article ID: 139746
Article Last Modified on 7/11/2005
119591 How to Obtain Microsoft Support Files from Online Services
setvideo <alias> palette handle to <palette handle>
// Include files.
#include <windows.h> // Required for all Windows applications
#include "windowsx.h" // for GlobalAllocPtr/GlobalFreePtr in
// CreateSamplePalette.
#include "mmsystem.h" // For the MCI calls.
// Global variables.
static HPALETTE g_hPal = NULL; // Palette handle.
.
.
.
// CreateSamplePalette() demonstrates how to fill in a LOGPALETTE
// structure and create a logical palette.
VOID CreateSamplePalette(void)
{
LPLOGPALETTE lpLogPal;
int i;
int nPalEntries = 236; // Number of entries in our
// palette.
// 256 are possible, but the
// system reserves 20 of them.
lpLogPal = (LPLOGPALETTE) GlobalAllocPtr (GHND,
sizeof (LOGPALETTE) + nPalEntries * sizeof
(PALETTEENTRY));
lpLogPal->palVersion = 0x300;
lpLogPal->palNumEntries = nPalEntries;
for (i = nPalEntries; i > 0; i--)
{
// Fill in the red, green, and blue values for our palette.
// This particular palette is a wash from green to black.
lpLogPal->palPalEntry[i].peRed = 0;
lpLogPal->palPalEntry[i].peGreen = i;
lpLogPal->palPalEntry[i].peBlue = 0;
// Create unique palette entries. This flag may change depending
// on your purposes. See the Windows API documentation
// about the PALETTEENTRY structure for more information.
lpLogPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
}
// Create the logical palette.
g_hPal = CreatePalette (lpLogPal);
// Clean up.
GlobalFreePtr (lpLogPal);
}
// The ProcessAVICommands() function in SETPAL.C handles the open, set
// palette, play, and close for the AVI file. Once the AVI file has been
// opened, issue an mciSendString() such as the following to set the
// palette:
static char szAlias[10] = "paltest"; // The movie alias to use in
mciSendString // buffer to hold the MCI
char szBuffer[128]; // string we built.
.
.
.
wsprintf(szBuffer, "setvideo %s palette handle to %d",
(LPSTR)szAlias, g_hPal);
mciSendString(szBuffer, NULL, 0, NULL);
Additional query words: mciSendCommand MCI_SETVIDEO MCI_DGV_SETVIDEO_ITEM MCI_DGV_SETVIDEO_PALHANDLE
Keywords: kbdownload kbcode kbfile kbmm kbsample KB139746