Microsoft DirectX 9.0

CBaseWindow::SetPalette

The SetPalette method installs a palette for the window.

Syntax

virtual HRESULT SetPalette(
    HPALETTE hPalette
);

HRESULT SetPalette(void);

Parameters

hPalette

Handle to the new palette. Cannot be NULL.

Return Value

Returns one of the HRESULT values shown in the following table.

Value Description
S_FALSE An internal call to GdiFlush returned an error.
S_OK Success.

Remarks

The hPalette parameter specifies a new palette. If the method is called with no parameters, the palette given by the CBaseWindow::m_hPalette member variable is selected. The caller must ensure the validity of m_hPalette.

If the value of the CBaseWindow::m_bNoRealize member variable is FALSE (the default), this method selects the palette and realizes it. Otherwise, it selects the palette but does not realize it. The object does not delete any previous palette that it was using. The caller is responsible for deleting palettes.

Any thread can safely call this method, not just the thread that owns the window. The window sends a private message to itself, which triggers a call to the CBaseWindow::OnPaletteChange method.

See Also