CBaseWindow.SetPalette method (Winutil.h)

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The SetPalette method installs a palette for the window.

Syntax

virtual HRESULT SetPalette(
   HPALETTE hPalette
);

Parameters

hPalette

Handle to the new palette. Cannot be NULL.

Return value

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

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

Remarks

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.

Requirements

Requirement Value
Header
Winutil.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)

See also

CBaseWindow Class