Show: Delphi C++
Display Preferences

Vcl.Controls.TWinControl.PaletteChanged

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function PaletteChanged(Foreground: Boolean): Boolean; override;

C++

DYNAMIC bool __fastcall PaletteChanged(bool Foreground);

Properties

Type Visibility Source Unit Parent
function protected
Vcl.Controls.pas
Vcl.Controls.hpp
Vcl.Controls TWinControl

Description

Responds to changes in the system's palette by realizing the control's palette and the palette for each child control.

PaletteChanged is called automatically when the Windows system palette changes. TWinControl responds to these notifications by trying to realize the windowed control's palette, if any, into the current device context, and then passing on the PaletteChanged notification to each of the child controls in turn. If the change in the system palette causes the actual value of the control's palette to change, PaletteChanged will invalidate the control so that it can repaint with the new palette.

Windows paints the active window with a foreground palette, while other windows are forced to use background palettes. Background palettes are approximate matches to the colors specified by the control's logical palette, given the limitations imposed by implementing the foreground palette. Windows only allows a single foreground palette.

PaletteChanged allows the control to obtain a new realization of its palette when the system palette changes. When Foreground is true, the form has been activated and the control is specifying the new foreground palette. When Foreground is false, another application or form has changed the foreground palette, and controls that are sensitive to the available palette should realize new background palettes to best match their logical palettes.

If the control does not have a logical palette to be realized into the current device context, GetPalette will return a handle of 0, and PaletteChanged will not try to realize a palette for the windowed control. Instead, it simply passes the notification on to the child controls. If the windowed control or any of its child controls realize a palette into the current device context in response to PaletteChanged, this method returns true.

Override PaletteChanged to change the way in which controls are given an opportunity to realize a new palette when the Windows system palette changes. For example, override PaletteChanged to change the order in which child controls realize their palettes, giving a particular control the foreground palette when the form is activated, or to pass palette change notification to custom controls implemented outside of the VCL, such as in DLLs.

Override GetPalette instead to affect whether the windowed control actually has a palette to realize, or to change the value of the control's logical palette.

Note: PaletteChanged is called only when the run-time video mode requires palette support, such as for 256 color mode, but not 16 million color mode.

See Also

Personal tools
In Other Languages
Previous Versions
Assistance