4 * Copyright 1993,1994 Alexandre Julliard
5 * Copyright 1996 Alex Korobka
7 * PALETTEOBJ is documented in the Dr. Dobbs Journal May 1993.
8 * Information in the "Undocumented Windows" is incorrect.
21 static UINT32 SystemPaletteUse
= SYSPAL_STATIC
; /* currently not considered */
23 static HPALETTE16 hPrimaryPalette
= 0; /* used for WM_PALETTECHANGED */
24 static HPALETTE16 hLastRealizedPalette
= 0; /* UnrealizeObject() needs it */
27 /***********************************************************************
30 * Create the system palette.
32 HPALETTE16
PALETTE_Init(void)
38 const PALETTEENTRY
* __sysPalTemplate
= COLOR_GetSystemPaletteTemplate();
40 /* create default palette (20 system colors) */
42 palPtr
= HeapAlloc( GetProcessHeap(), 0,
43 sizeof(LOGPALETTE
) + (NB_RESERVED_COLORS
-1)*sizeof(PALETTEENTRY
));
44 if (!palPtr
) return FALSE
;
46 palPtr
->palVersion
= 0x300;
47 palPtr
->palNumEntries
= NB_RESERVED_COLORS
;
48 for( i
= 0; i
< NB_RESERVED_COLORS
; i
++ )
50 palPtr
->palPalEntry
[i
].peRed
= __sysPalTemplate
[i
].peRed
;
51 palPtr
->palPalEntry
[i
].peGreen
= __sysPalTemplate
[i
].peGreen
;
52 palPtr
->palPalEntry
[i
].peBlue
= __sysPalTemplate
[i
].peBlue
;
53 palPtr
->palPalEntry
[i
].peFlags
= 0;
55 hpalette
= CreatePalette16( palPtr
);
57 palObj
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
59 palObj
->mapping
= xmalloc( sizeof(int) * 20 );
61 GDI_HEAP_UNLOCK( hpalette
);
63 HeapFree( GetProcessHeap(), 0, palPtr
);
67 /***********************************************************************
68 * PALETTE_ValidateFlags
70 void PALETTE_ValidateFlags(PALETTEENTRY
* lpPalE
, int size
)
74 lpPalE
[i
].peFlags
= PC_SYS_USED
| (lpPalE
[i
].peFlags
& 0x07);
78 /***********************************************************************
79 * CreatePalette16 (GDI.360)
81 HPALETTE16 WINAPI
CreatePalette16( const LOGPALETTE
* palette
)
83 return CreatePalette32( palette
);
87 /***********************************************************************
88 * CreatePalette32 [GDI32.53] Creates a logical color palette
91 * Success: Handle to logical palette
94 HPALETTE32 WINAPI
CreatePalette32(
95 const LOGPALETTE
* palette
) /* [in] Pointer to logical color palette */
97 PALETTEOBJ
* palettePtr
;
99 int size
= sizeof(LOGPALETTE
) + (palette
->palNumEntries
- 1) * sizeof(PALETTEENTRY
);
101 TRACE(palette
,"entries=%i\n", palette
->palNumEntries
);
103 hpalette
= GDI_AllocObject( size
+ sizeof(int*) +sizeof(GDIOBJHDR
) , PALETTE_MAGIC
);
104 if (!hpalette
) return 0;
106 palettePtr
= (PALETTEOBJ
*) GDI_HEAP_LOCK( hpalette
);
107 memcpy( &palettePtr
->logpalette
, palette
, size
);
108 PALETTE_ValidateFlags(palettePtr
->logpalette
.palPalEntry
,
109 palettePtr
->logpalette
.palNumEntries
);
110 palettePtr
->mapping
= NULL
;
111 GDI_HEAP_UNLOCK( hpalette
);
113 TRACE(palette
," returning %04x\n", hpalette
);
118 /***********************************************************************
119 * CreateHalftonePalette [GDI32.47] Creates a halftone palette
122 * Success: Handle to logical halftone palette
125 HPALETTE32 WINAPI
CreateHalftonePalette(
126 HDC32 hdc
) /* [in] Handle to device context */
128 FIXME(palette
,"(%x): stub\n", hdc
);
133 /***********************************************************************
134 * GetPaletteEntries16 (GDI.363)
136 UINT16 WINAPI
GetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
137 UINT16 count
, LPPALETTEENTRY entries
)
139 return GetPaletteEntries32( hpalette
, start
, count
, entries
);
143 /***********************************************************************
144 * GetPaletteEntries32 [GDI32.209] Retrieves palette entries
147 * Success: Number of entries from logical palette
150 UINT32 WINAPI
GetPaletteEntries32(
151 HPALETTE32 hpalette
, /* [in] Handle of logical palette */
152 UINT32 start
, /* [in] First entry to receive */
153 UINT32 count
, /* [in] Number of entries to receive */
154 LPPALETTEENTRY entries
) /* [out] Address of array receiving entries */
159 TRACE(palette
,"hpal = %04x, count=%i\n", hpalette
, count
);
161 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
162 if (!palPtr
) return 0;
164 numEntries
= palPtr
->logpalette
.palNumEntries
;
165 if (start
>= numEntries
)
167 GDI_HEAP_UNLOCK( hpalette
);
170 if (start
+count
> numEntries
) count
= numEntries
- start
;
171 memcpy( entries
, &palPtr
->logpalette
.palPalEntry
[start
],
172 count
* sizeof(PALETTEENTRY
) );
173 for( numEntries
= 0; numEntries
< count
; numEntries
++ )
174 if (entries
[numEntries
].peFlags
& 0xF0)
175 entries
[numEntries
].peFlags
= 0;
176 GDI_HEAP_UNLOCK( hpalette
);
181 /***********************************************************************
182 * SetPaletteEntries16 (GDI.364)
184 UINT16 WINAPI
SetPaletteEntries16( HPALETTE16 hpalette
, UINT16 start
,
185 UINT16 count
, LPPALETTEENTRY entries
)
187 return SetPaletteEntries32( hpalette
, start
, count
, entries
);
191 /***********************************************************************
192 * SetPaletteEntries32 [GDI32.326] Sets color values for range in palette
195 * Success: Number of entries that were set
198 UINT32 WINAPI
SetPaletteEntries32(
199 HPALETTE32 hpalette
, /* [in] Handle of logical palette */
200 UINT32 start
, /* [in] Index of first entry to set */
201 UINT32 count
, /* [in] Number of entries to set */
202 LPPALETTEENTRY entries
) /* [in] Address of array of structures */
207 TRACE(palette
,"hpal=%04x,start=%i,count=%i\n",hpalette
,start
,count
);
209 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
210 if (!palPtr
) return 0;
212 numEntries
= palPtr
->logpalette
.palNumEntries
;
213 if (start
>= numEntries
)
215 GDI_HEAP_UNLOCK( hpalette
);
218 if (start
+count
> numEntries
) count
= numEntries
- start
;
219 memcpy( &palPtr
->logpalette
.palPalEntry
[start
], entries
,
220 count
* sizeof(PALETTEENTRY
) );
221 PALETTE_ValidateFlags(palPtr
->logpalette
.palPalEntry
,
222 palPtr
->logpalette
.palNumEntries
);
223 free(palPtr
->mapping
);
224 palPtr
->mapping
= NULL
;
225 GDI_HEAP_UNLOCK( hpalette
);
230 /***********************************************************************
231 * ResizePalette16 (GDI.368)
233 BOOL16 WINAPI
ResizePalette16( HPALETTE16 hPal
, UINT16 cEntries
)
235 return ResizePalette32( hPal
, cEntries
);
239 /***********************************************************************
240 * ResizePalette32 [GDI32.289] Resizes logical palette
246 BOOL32 WINAPI
ResizePalette32(
247 HPALETTE32 hPal
, /* [in] Handle of logical palette */
248 UINT32 cEntries
) /* [in] Number of entries in logical palette */
250 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hPal
, PALETTE_MAGIC
);
251 UINT32 cPrevEnt
, prevVer
;
252 int prevsize
, size
= sizeof(LOGPALETTE
) + (cEntries
- 1) * sizeof(PALETTEENTRY
);
255 TRACE(palette
,"hpal = %04x, prev = %i, new = %i\n",
256 hPal
, palPtr
? palPtr
->logpalette
.palNumEntries
: -1,
258 if( !palPtr
) return FALSE
;
259 cPrevEnt
= palPtr
->logpalette
.palNumEntries
;
260 prevVer
= palPtr
->logpalette
.palVersion
;
261 prevsize
= sizeof(LOGPALETTE
) + (cPrevEnt
- 1) * sizeof(PALETTEENTRY
) +
262 sizeof(int*) + sizeof(GDIOBJHDR
);
263 size
+= sizeof(int*) + sizeof(GDIOBJHDR
);
264 mapping
= palPtr
->mapping
;
266 GDI_HEAP_UNLOCK( hPal
);
268 hPal
= GDI_HEAP_REALLOC( hPal
, size
);
269 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( hPal
, PALETTE_MAGIC
);
270 if( !palPtr
) return FALSE
;
273 palPtr
->mapping
= (int*) xrealloc( mapping
, cEntries
* sizeof(int) );
274 if( cEntries
> cPrevEnt
)
277 memset(palPtr
->mapping
+ cPrevEnt
, 0, (cEntries
- cPrevEnt
)*sizeof(int));
278 memset( (BYTE
*)palPtr
+ prevsize
, 0, size
- prevsize
);
279 PALETTE_ValidateFlags((PALETTEENTRY
*)((BYTE
*)palPtr
+ prevsize
),
280 cEntries
- cPrevEnt
);
282 palPtr
->logpalette
.palNumEntries
= cEntries
;
283 palPtr
->logpalette
.palVersion
= prevVer
;
284 GDI_HEAP_UNLOCK( hPal
);
289 /***********************************************************************
290 * AnimatePalette16 (GDI.367)
292 void WINAPI
AnimatePalette16( HPALETTE16 hPal
, UINT16 StartIndex
,
293 UINT16 NumEntries
, LPPALETTEENTRY PaletteColors
)
295 AnimatePalette32( hPal
, StartIndex
, NumEntries
, PaletteColors
);
299 /***********************************************************************
300 * AnimatePalette32 [GDI32.6] Replaces entries in logical palette
307 * Should use existing mapping when animating a primary palette
309 BOOL32 WINAPI
AnimatePalette32(
310 HPALETTE32 hPal
, /* [in] Handle to logical palette */
311 UINT32 StartIndex
, /* [in] First entry in palette */
312 UINT32 NumEntries
, /* [in] Count of entries in palette */
313 LPPALETTEENTRY PaletteColors
) /* [in] Pointer to first replacement */
315 TRACE(palette
, "%04x (%i - %i)\n", hPal
, StartIndex
,StartIndex
+NumEntries
);
317 if( hPal
!= STOCK_DEFAULT_PALETTE
)
319 PALETTEOBJ
* palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr(hPal
, PALETTE_MAGIC
);
321 if( (StartIndex
+ NumEntries
) <= palPtr
->logpalette
.palNumEntries
)
324 for( u
= 0; u
< NumEntries
; u
++ )
325 palPtr
->logpalette
.palPalEntry
[u
+ StartIndex
] = PaletteColors
[u
];
326 COLOR_SetMapping(palPtr
, StartIndex
, NumEntries
,
327 hPal
!= hPrimaryPalette
);
328 GDI_HEAP_UNLOCK( hPal
);
336 /***********************************************************************
337 * SetSystemPaletteUse16 (GDI.373)
339 UINT16 WINAPI
SetSystemPaletteUse16( HDC16 hdc
, UINT16 use
)
341 return SetSystemPaletteUse32( hdc
, use
);
345 /***********************************************************************
346 * SetSystemPaletteUse32 [GDI32.335]
349 * Success: Previous system palette
350 * Failure: SYSPAL_ERROR
352 UINT32 WINAPI
SetSystemPaletteUse32(
353 HDC32 hdc
, /* [in] Handle of device context */
354 UINT32 use
) /* [in] Palette-usage flag */
356 UINT32 old
= SystemPaletteUse
;
357 FIXME(palette
,"(%04x,%04x): stub\n", hdc
, use
);
358 SystemPaletteUse
= use
;
363 /***********************************************************************
364 * GetSystemPaletteUse16 (GDI.374)
366 UINT16 WINAPI
GetSystemPaletteUse16( HDC16 hdc
)
368 return SystemPaletteUse
;
372 /***********************************************************************
373 * GetSystemPaletteUse32 [GDI32.223] Gets state of system palette
376 * Current state of system palette
378 UINT32 WINAPI
GetSystemPaletteUse32(
379 HDC32 hdc
) /* [in] Handle of device context */
381 return SystemPaletteUse
;
385 /***********************************************************************
386 * GetSystemPaletteEntries16 (GDI.375)
388 UINT16 WINAPI
GetSystemPaletteEntries16( HDC16 hdc
, UINT16 start
, UINT16 count
,
389 LPPALETTEENTRY entries
)
391 return GetSystemPaletteEntries32( hdc
, start
, count
, entries
);
395 /***********************************************************************
396 * GetSystemPaletteEntries32 [GDI32.222] Gets range of palette entries
399 * Success: Number of entries retrieved from palette
402 UINT32 WINAPI
GetSystemPaletteEntries32(
403 HDC32 hdc
, /* [in] Handle of device context */
404 UINT32 start
, /* [in] Index of first entry to be retrieved */
405 UINT32 count
, /* [in] Number of entries to be retrieved */
406 LPPALETTEENTRY entries
) /* [out] Array receiving system-palette entries */
411 TRACE(palette
, "hdc=%04x,start=%i,count=%i\n", hdc
,start
,count
);
413 if (!(dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
))) return 0;
414 if (start
>= dc
->w
.devCaps
->sizePalette
)
416 GDI_HEAP_UNLOCK( hdc
);
419 if (start
+count
>= dc
->w
.devCaps
->sizePalette
)
420 count
= dc
->w
.devCaps
->sizePalette
- start
;
421 for (i
= 0; i
< count
; i
++)
423 *(COLORREF
*)(entries
+ i
) = COLOR_GetSystemPaletteEntry( start
+ i
);
425 TRACE(palette
,"\tidx(%02x) -> RGB(%08lx)\n",
426 start
+ i
, *(COLORREF
*)(entries
+ i
) );
428 GDI_HEAP_UNLOCK( hdc
);
433 /***********************************************************************
434 * GetNearestPaletteIndex16 (GDI.370)
436 UINT16 WINAPI
GetNearestPaletteIndex16( HPALETTE16 hpalette
, COLORREF color
)
438 return GetNearestPaletteIndex32( hpalette
, color
);
442 /***********************************************************************
443 * GetNearestPaletteIndex32 [GDI32.203] Gets palette index for color
446 * Should index be initialized to CLR_INVALID instead of 0?
449 * Success: Index of entry in logical palette
450 * Failure: CLR_INVALID
452 UINT32 WINAPI
GetNearestPaletteIndex32(
453 HPALETTE32 hpalette
, /* [in] Handle of logical color palette */
454 COLORREF color
) /* [in] Color to be matched */
456 PALETTEOBJ
* palObj
= (PALETTEOBJ
*)GDI_GetObjPtr( hpalette
, PALETTE_MAGIC
);
460 index
= COLOR_PaletteLookupPixel( palObj
->logpalette
.palPalEntry
,
461 palObj
->logpalette
.palNumEntries
,
462 NULL
, color
, FALSE
);
464 TRACE(palette
,"(%04x,%06lx): returning %d\n", hpalette
, color
, index
);
465 GDI_HEAP_UNLOCK( hpalette
);
470 /***********************************************************************
471 * GetNearestColor16 (GDI.154)
473 COLORREF WINAPI
GetNearestColor16( HDC16 hdc
, COLORREF color
)
475 return GetNearestColor32( hdc
, color
);
479 /***********************************************************************
480 * GetNearestColor32 [GDI32.202] Gets a system color to match
483 * Should this return CLR_INVALID instead of FadeCafe?
486 * Success: Color from system palette that corresponds to given color
487 * Failure: CLR_INVALID
489 COLORREF WINAPI
GetNearestColor32(
490 HDC32 hdc
, /* [in] Handle of device context */
491 COLORREF color
) /* [in] Color to be matched */
493 COLORREF nearest
= 0xFADECAFE;
497 if ( (dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
)) )
499 palObj
= (PALETTEOBJ
*)
500 GDI_GetObjPtr( (dc
->w
.hPalette
)? dc
->w
.hPalette
501 : STOCK_DEFAULT_PALETTE
, PALETTE_MAGIC
);
503 nearest
= COLOR_LookupNearestColor( palObj
->logpalette
.palPalEntry
,
504 palObj
->logpalette
.palNumEntries
, color
);
505 GDI_HEAP_UNLOCK( dc
->w
.hPalette
);
508 TRACE(palette
,"(%06lx): returning %06lx\n", color
, nearest
);
509 GDI_HEAP_UNLOCK( hdc
);
514 /***********************************************************************
517 int PALETTE_GetObject( PALETTEOBJ
* palette
, int count
, LPSTR buffer
)
519 if (count
> sizeof(WORD
)) count
= sizeof(WORD
);
520 memcpy( buffer
, &palette
->logpalette
.palNumEntries
, count
);
525 /***********************************************************************
526 * PALETTE_UnrealizeObject
528 BOOL32
PALETTE_UnrealizeObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
530 if (palette
->mapping
)
532 free( palette
->mapping
);
533 palette
->mapping
= NULL
;
535 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
540 /***********************************************************************
541 * PALETTE_DeleteObject
543 BOOL32
PALETTE_DeleteObject( HPALETTE16 hpalette
, PALETTEOBJ
*palette
)
545 free( palette
->mapping
);
546 if (hLastRealizedPalette
== hpalette
) hLastRealizedPalette
= 0;
547 return GDI_FreeObject( hpalette
);
551 /***********************************************************************
552 * GDISelectPalette (GDI.361)
554 HPALETTE16 WINAPI
GDISelectPalette( HDC16 hdc
, HPALETTE16 hpal
, WORD wBkg
)
559 TRACE(palette
, "%04x %04x\n", hdc
, hpal
);
561 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
564 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
567 prev
= dc
->w
.hPalette
;
568 dc
->w
.hPalette
= hpal
;
569 GDI_HEAP_UNLOCK( hdc
);
570 if (!wBkg
) hPrimaryPalette
= hpal
;
575 /***********************************************************************
576 * GDIRealizePalette (GDI.362)
578 UINT16 WINAPI
GDIRealizePalette( HDC16 hdc
)
582 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
585 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
589 TRACE(palette
, "%04x...\n", hdc
);
591 if( dc
&& dc
->w
.hPalette
!= hLastRealizedPalette
)
593 if( dc
->w
.hPalette
== STOCK_DEFAULT_PALETTE
)
594 return RealizeDefaultPalette( hdc
);
596 palPtr
= (PALETTEOBJ
*) GDI_GetObjPtr( dc
->w
.hPalette
, PALETTE_MAGIC
);
598 realized
= COLOR_SetMapping(palPtr
,0,palPtr
->logpalette
.palNumEntries
,
599 (dc
->w
.hPalette
!= hPrimaryPalette
) ||
600 (dc
->w
.hPalette
== STOCK_DEFAULT_PALETTE
));
601 GDI_HEAP_UNLOCK( dc
->w
.hPalette
);
602 hLastRealizedPalette
= dc
->w
.hPalette
;
604 else TRACE(palette
, " skipping (hLastRealizedPalette = %04x)\n",
605 hLastRealizedPalette
);
606 GDI_HEAP_UNLOCK( hdc
);
608 TRACE(palette
, " realized %i colors.\n", realized
);
609 return (UINT16
)realized
;
613 /***********************************************************************
614 * RealizeDefaultPalette (GDI.365)
616 UINT16 WINAPI
RealizeDefaultPalette( HDC16 hdc
)
620 int i
, index
, realized
= 0;
622 TRACE(palette
,"%04x\n", hdc
);
624 dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
627 dc
= (DC
*)GDI_GetObjPtr(hdc
, METAFILE_DC_MAGIC
);
631 if ( dc
->w
.flags
& DC_MEMORY
)
633 GDI_HEAP_UNLOCK( hdc
);
637 hPrimaryPalette
= STOCK_DEFAULT_PALETTE
;
638 hLastRealizedPalette
= STOCK_DEFAULT_PALETTE
;
640 palPtr
= (PALETTEOBJ
*)GDI_GetObjPtr(STOCK_DEFAULT_PALETTE
, PALETTE_MAGIC
);
642 /* lookup is needed to account for SetSystemPaletteUse() stuff */
644 for( i
= 0; i
< 20; i
++ )
646 index
= COLOR_LookupSystemPixel(*(COLORREF
*)(palPtr
->logpalette
.palPalEntry
+ i
));
648 /* mapping is allocated in COLOR_InitPalette() */
650 if( index
!= palPtr
->mapping
[i
] ) { palPtr
->mapping
[i
]=index
; realized
++; }
655 /***********************************************************************
656 * IsDCCurrentPalette (GDI.412)
658 BOOL16 WINAPI
IsDCCurrentPalette(HDC16 hDC
)
660 DC
* dc
= (DC
*)GDI_GetObjPtr( hDC
, DC_MAGIC
);
663 GDI_HEAP_UNLOCK( hDC
);
664 return dc
->w
.hPalette
== hPrimaryPalette
;
670 /***********************************************************************
671 * SelectPalette16 (USER.282)
673 HPALETTE16 WINAPI
SelectPalette16( HDC16 hDC
, HPALETTE16 hPal
,
674 BOOL16 bForceBackground
)
676 return SelectPalette32( hDC
, hPal
, bForceBackground
);
680 /***********************************************************************
681 * SelectPalette32 [GDI32.300] Selects logical palette into DC
684 * Success: Previous logical palette
687 HPALETTE32 WINAPI
SelectPalette32(
688 HDC32 hDC
, /* [in] Handle of device context */
689 HPALETTE32 hPal
, /* [in] Handle of logical color palette */
690 BOOL32 bForceBackground
) /* [in] Foreground/background mode */
692 WORD wBkgPalette
= 1;
693 PALETTEOBJ
* lpt
= (PALETTEOBJ
*) GDI_GetObjPtr( hPal
, PALETTE_MAGIC
);
695 TRACE(palette
,"dc=%04x,pal=%04x,force=%i\n", hDC
, hPal
, bForceBackground
);
698 TRACE(palette
," entries = %d\n", lpt
->logpalette
.palNumEntries
);
699 GDI_HEAP_UNLOCK( hPal
);
701 if( hPal
!= STOCK_DEFAULT_PALETTE
)
703 HWND32 hWnd
= WindowFromDC32( hDC
);
704 HWND32 hActive
= GetActiveWindow32();
706 /* set primary palette if it's related to current active */
708 if((!hWnd
|| (hActive
== hWnd
|| IsChild16(hActive
,hWnd
))) &&
712 return GDISelectPalette( hDC
, hPal
, wBkgPalette
);
716 /***********************************************************************
717 * RealizePalette16 (USER.283)
719 UINT16 WINAPI
RealizePalette16( HDC16 hDC
)
721 return RealizePalette32( hDC
);
725 /***********************************************************************
726 * RealizePalette32 [GDI32.280] Maps palette entries to system palette
729 * Success: Number of entries in logical palette
732 UINT32 WINAPI
RealizePalette32(
733 HDC32 hDC
) /* [in] Handle of device context */
735 UINT32 realized
= GDIRealizePalette( hDC
);
737 /* do not send anything if no colors were changed */
739 if( IsDCCurrentPalette( hDC
) && realized
&&
740 !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL
) )
742 /* Send palette change notification */
745 if( (hWnd
= WindowFromDC32( hDC
)) )
746 SendMessage16( HWND_BROADCAST
, WM_PALETTECHANGED
, hWnd
, 0L);
752 /**********************************************************************
753 * UpdateColors16 (GDI.366)
755 INT16 WINAPI
UpdateColors16( HDC16 hDC
)
757 HWND32 hWnd
= WindowFromDC32( hDC
);
759 /* Docs say that we have to remap current drawable pixel by pixel
760 * but it would take forever given the speed of XGet/PutPixel.
762 if (hWnd
&& !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL
) )
763 InvalidateRect32( hWnd
, NULL
, FALSE
);
768 /**********************************************************************
769 * UpdateColors32 [GDI32.359] Remaps current colors to logical palette
775 BOOL32 WINAPI
UpdateColors32(
776 HDC32 hDC
) /* [in] Handle of device context */
778 UpdateColors16( hDC
);