[comp.windows.ms.programmer] Palettes

gt3070b@prism.gatech.EDU (Jeff Watkins) (05/22/91)

I have a problem with using windows palettes.

What I am trying to do is to define two pens with palette relative colors.
These two pens live in a dll where functions make use of them with user
defined palettes or the dll's default palette.  If I use the default
palette, and never use an application defined palette, all seems to work
ok.  However, if I do use an application palette, those pens will be
forever the colors from that palette.  If I happen to use the default
palette first, then the user palette will never show.

What I need to know is, does windows fix-up palette relative references
when they are selected?  And if so, is there any other way to do what I am
trying to do?

thanks for the help...

ciao
jeff

-- 
Jeff Watkins                       jwatkins@cadsun6.gatech.edu
Lotus Development WP Devision      (404) 315-0105 voice  (404) 315-0231 data
		"It isn't whether the child lives or dies,
			It is who makes the decision."

bonneau@hyper.hyper.com (Paul Bonneau) (05/22/91)

In article <29582@hydra.gatech.EDU> gt3070b@prism.gatech.EDU
(Jeff Watkins) writes:
>I have a problem with using windows palettes.
>
>What I am trying to do is to define two pens with palette relative colors.
>These two pens live in a dll where functions make use of them with user
>defined palettes or the dll's default palette.  If I use the default
>palette, and never use an application defined palette, all seems to work
>ok.  However, if I do use an application palette, those pens will be
>forever the colors from that palette.  If I happen to use the default
>palette first, then the user palette will never show.
>
>What I need to know is, does windows fix-up palette relative references
>when they are selected?  And if so, is there any other way to do what I am
>trying to do?
>
I had similar problems.  Mine were due to not catching the
WM_QUERYNEWPALETTE message.  Each app that wants to use its
own palette needs to have this case in its main window proc
and respond with code something like:

	case WM_QUERYNEWPALETTE:
		{
		HDC	hdc;
		int	centMapped;

		hdc = GetDC(hwnd);
		SelectPalette(hdc, hPalette, 0);
		centMapped = RealizePalette(hdc);
		ReleaseDC(hwnd, hdc);
		if (centMapped != 0)
			{
			InvalidateRect(hwnd, lprectNull, fTrue);
			return fTrue;
			}
		}
		break;

cheers - Paul Bonneau.

P.S.	You're welcome Brett.
	return fFalse;
	}