Newsgroups: comp.windows.ms.programmer Path: utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau From: bonneau@hyper.hyper.com (Paul Bonneau) Subject: Re: Palettes Message-ID: <1991May22.165744.27572@hyper.hyper.com> Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,) Organization: HyperCube Inc. References: <29582@hydra.gatech.EDU> Date: Wed, 22 May 1991 16:57:44 GMT 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; }