/* * @implemented */ BOOL WINAPI SetSysColors( int cElements, CONST INT *lpaElements, CONST COLORREF *lpaRgbValues) { return NtUserSetSysColors(cElements, lpaElements, lpaRgbValues, 0); }
WINUSERAPI HANDLE WINAPI SetSysColorsTemp( CONST COLORREF *lpRGBs, CONST HBRUSH *lpBrushes, UINT_PTR cBrushes) // Count of brushes or handle { UINT cbRGBSize; UINT i; UINT abElements[COLOR_MAX]; /* * See if we are resetting the colors back to a saved state */ if (lpRGBs == NULL) { /* * When restoring cBrushes is really a handle to the old global * handle. Make sure that is true. Also lpBrushes is unused */ UNREFERENCED_PARAMETER(lpBrushes); UserAssert(lpBrushes == NULL); UserAssert(cBrushes == (ULONG_PTR)gpOriginalRGBs); if (gpOriginalRGBs == NULL) { RIPMSG0(RIP_ERROR, "SetSysColorsTemp: Can not restore if not saved"); return NULL; } /* * reset the global Colors */ UserAssert((sizeof(abElements)/sizeof(abElements[0])) >= gcOriginalRGBs); for (i = 0; i < gcOriginalRGBs; i++) abElements[i] = i; NtUserSetSysColors(gcOriginalRGBs, abElements, gpOriginalRGBs, 0); UserLocalFree(gpOriginalRGBs); gpOriginalRGBs = NULL; gcOriginalRGBs = 0; return (HANDLE)TRUE; } /* * Make sure we aren't trying to set too many colors * If we allow more then COLOR_MAX change the abElements array */ if (cBrushes > COLOR_MAX) { RIPMSG1(RIP_ERROR, "SetSysColorsTemp: trying to set too many colors %lX", cBrushes); return NULL; } /* * If we have already a saved state then don't let them save it again */ if (gpOriginalRGBs != NULL) { RIPMSG0(RIP_ERROR, "SetSysColorsTemp: temp colors already set"); return NULL; } /* * If we are here then we must be setting the new temp colors * * First save the old colors */ cbRGBSize = sizeof(COLORREF) * (UINT)cBrushes; UserAssert(sizeof(COLORREF) == sizeof(int)); gpOriginalRGBs = UserLocalAlloc(HEAP_ZERO_MEMORY, cbRGBSize); if (gpOriginalRGBs == NULL) { RIPMSG0(RIP_WARNING, "SetSysColorsTemp: unable to alloc temp colors buffer"); } RtlCopyMemory(gpOriginalRGBs, gpsi->argbSystem, cbRGBSize); /* * Now set the new colors. */ UserAssert( (sizeof(abElements)/sizeof(abElements[0])) >= cBrushes); for (i = 0; i < cBrushes; i++) abElements[i] = i; NtUserSetSysColors((UINT)cBrushes, abElements, lpRGBs, 0); gcOriginalRGBs = (UINT)cBrushes; return gpOriginalRGBs; }