Board index » cppbuilder » Controls prefer 16 colour to logical palette

Controls prefer 16 colour to logical palette

Palette gurus,

I have a form with a number of controls. The controls are colored in colors
that are in the logical palette that I have created, _however_ the controls
don't display using this palette, they just dither from the 16 color
palette.

Questions:
1) How do I make a control use a color in the logical palette?
The following picks up the correct palette index...
GetNearestPaletteIndex(fLogicalPalette,COLORREF(Shape1->Brush->Color))
... but I don't know how to correctly assign this color to the control.
Interestingly though is that
GetNearestColor(hDC, COLORREF(Shape1->Brush->Color))
returns one of the 16 colors even though the system pallette does contain
the required color.

2) I am aware that an old trick is to display a bitmap on the form
containing all the required colors, that way any controls needing those
colors will see that they are available and won't dither from the standard
set of 16. Well, I tried this and it didn't work, although the bitmap looked
great :-(

3) I'm not Robinson Crusoe on this one, so is there a reference/resource I
can use to help my tired brain? My approach so far has been a 5-day exercise
in Windows palette manipulation, writing what looks a lot like Windows
Petzold Hieroglyphics than elegant BCB.

Thanks in advance
Garron

 

Re:Controls prefer 16 colour to logical palette


Quote
Garron Lipschitz <mandy_gar...@one.net.au> wrote:
>3) I'm not Robinson Crusoe on this one, so is there a reference/resource I
>can use to help my tired brain? My approach so far has been a 5-day exercise
>in Windows palette manipulation, writing what looks a lot like Windows
>Petzold Hieroglyphics than elegant BCB.

I can't help you with your question;
but have you been using the BCB function GetPalette?
You return a palette for any of your things that are descended from
TControl and VCL handles a lot of stuff (ie. WM_QUERYNEWPALETTE,
WM_PALETTECHANGED, ...)

My understanding has always been that, if you want a bunch of painting to
use a palette, you must SelectPalette/RealizePalette on the HDC
immediately before it paints. Is this true? And are your controls doing
it?

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. ljw1...@cam.ac.uk

Other Threads