Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Support for system colors |
| 3 | * |
| 4 | * Copyright David W. Metcalfe, 1993 |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 5 | * Copyright Alexandre Julliard, 1994 |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 6 | * |
| 7 | */ |
| 8 | |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 9 | #include <assert.h> |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 10 | #include <stdio.h> |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 11 | #include <stdlib.h> |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 12 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 13 | #include "windef.h" |
| 14 | #include "wingdi.h" |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 15 | #include "wine/winbase16.h" |
| 16 | #include "wine/winuser16.h" |
| 17 | #include "sysmetrics.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 18 | #include "winbase.h" |
| 19 | #include "winuser.h" |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 20 | #include "debugtools.h" |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 21 | #include "tweak.h" |
Juergen Schmied | d0d1f15 | 1999-04-11 11:39:17 +0000 | [diff] [blame] | 22 | #include "winreg.h" |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 23 | #include "local.h" |
| 24 | #include "gdi.h" /* sic */ |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 25 | |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 26 | DEFAULT_DEBUG_CHANNEL(syscolor) |
| 27 | |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 28 | static const char * const DefSysColors[] = |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 29 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 30 | "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */ |
| 31 | "Background", "192 192 192", /* COLOR_BACKGROUND */ |
| 32 | "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */ |
| 33 | "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */ |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 34 | "Menu", "255 255 255", /* COLOR_MENU */ |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 35 | "Window", "255 255 255", /* COLOR_WINDOW */ |
| 36 | "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */ |
| 37 | "MenuText", "0 0 0", /* COLOR_MENUTEXT */ |
| 38 | "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */ |
| 39 | "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */ |
| 40 | "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */ |
| 41 | "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */ |
| 42 | "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */ |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 43 | "Hilight", "224 224 224", /* COLOR_HIGHLIGHT */ |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 44 | "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */ |
| 45 | "ButtonFace", "192 192 192", /* COLOR_BTNFACE */ |
| 46 | "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */ |
| 47 | "GrayText", "192 192 192", /* COLOR_GRAYTEXT */ |
| 48 | "ButtonText", "0 0 0", /* COLOR_BTNTEXT */ |
| 49 | "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 50 | "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */ |
| 51 | "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */ |
| 52 | "3DLight", "192 192 192", /* COLOR_3DLIGHT */ |
| 53 | "InfoText", "0 0 0", /* COLOR_INFOTEXT */ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 54 | "InfoBackground", "255 255 192", /* COLOR_INFOBK */ |
| 55 | "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */ |
| 56 | "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */ |
| 57 | "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */ |
| 58 | "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */ |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 61 | static const char * const DefSysColors95[] = |
| 62 | { |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 63 | "Scrollbar", "223 223 223", /* COLOR_SCROLLBAR */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 64 | "Background", "192 192 192", /* COLOR_BACKGROUND */ |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 65 | "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */ |
| 66 | "InactiveTitle", "128 128 128", /* COLOR_INACTIVECAPTION */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 67 | "Menu", "192 192 192", /* COLOR_MENU */ |
| 68 | "Window", "255 255 255", /* COLOR_WINDOW */ |
| 69 | "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */ |
| 70 | "MenuText", "0 0 0", /* COLOR_MENUTEXT */ |
| 71 | "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */ |
| 72 | "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */ |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 73 | "ActiveBorder", "192 192 192", /* COLOR_ACTIVEBORDER */ |
| 74 | "InactiveBorder", "192 192 192", /* COLOR_INACTIVEBORDER */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 75 | "AppWorkspace", "128 128 128", /* COLOR_APPWORKSPACE */ |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 76 | "Hilight", "0 0 128", /* COLOR_HIGHLIGHT */ |
| 77 | "HilightText", "255 255 255", /* COLOR_HIGHLIGHTTEXT */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 78 | "ButtonFace", "192 192 192", /* COLOR_BTNFACE */ |
| 79 | "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */ |
Gerard Patel | fd08737 | 1999-07-23 19:18:37 +0000 | [diff] [blame] | 80 | "GrayText", "128 128 128", /* COLOR_GRAYTEXT */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 81 | "ButtonText", "0 0 0", /* COLOR_BTNTEXT */ |
| 82 | "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 83 | "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 84 | "3DDarkShadow", "0 0 0", /* COLOR_3DDKSHADOW */ |
Noomen Hamza | 24d4ebf | 1999-10-13 13:47:01 +0000 | [diff] [blame] | 85 | "3DLight", "192 192 192", /* COLOR_3DLIGHT */ |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 86 | "InfoText", "0 0 0", /* COLOR_INFOTEXT */ |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 87 | "InfoBackground", "255 255 192", /* COLOR_INFOBK */ |
| 88 | "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */ |
| 89 | "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */ |
| 90 | "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */ |
| 91 | "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 95 | #define NUM_SYS_COLORS (COLOR_GRADIENTINACTIVECAPTION+1) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 96 | |
| 97 | static COLORREF SysColors[NUM_SYS_COLORS]; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 98 | static HBRUSH SysColorBrushes[NUM_SYS_COLORS]; |
| 99 | static HPEN SysColorPens[NUM_SYS_COLORS]; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 100 | |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 101 | #define MAKE_SOLID(color) \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 102 | (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color)))) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 103 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 104 | |
| 105 | /************************************************************************* |
| 106 | * SYSCOLOR_MakeObjectSystem |
| 107 | * |
| 108 | * OK, now for a very ugly hack. |
| 109 | * USER somehow has to tell GDI that its system brushes and pens are |
| 110 | * non-deletable. |
| 111 | * We don't want to export a function from GDI doing this for us, |
| 112 | * so we just do that ourselves by "wildly flipping some bits in memory". |
| 113 | * For a description of the GDI object magics and their flags, |
| 114 | * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though). |
| 115 | */ |
| 116 | static void SYSCOLOR_MakeObjectSystem( HGDIOBJ handle, BOOL set) |
| 117 | { |
| 118 | static WORD GDI_heap_sel = 0; |
| 119 | LPWORD ptr; |
| 120 | |
| 121 | if (!GDI_heap_sel) |
| 122 | { |
| 123 | GDI_heap_sel = LoadLibrary16("gdi"); |
| 124 | FreeLibrary16(GDI_heap_sel); |
| 125 | } |
| 126 | |
| 127 | ptr = (LPWORD)LOCAL_Lock(GDI_heap_sel, handle); |
| 128 | |
| 129 | /* touch the "system" bit of the wMagic field of a GDIOBJHDR */ |
| 130 | if (set) |
| 131 | *(ptr+1) &= ~OBJECT_NOSYSTEM; |
| 132 | else |
| 133 | *(ptr+1) |= OBJECT_NOSYSTEM; |
| 134 | LOCAL_Unlock( GDI_heap_sel, handle ); |
| 135 | } |
| 136 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 137 | /************************************************************************* |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 138 | * SYSCOLOR_SetColor |
| 139 | */ |
| 140 | static void SYSCOLOR_SetColor( int index, COLORREF color ) |
| 141 | { |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 142 | if (index < 0 || index >= NUM_SYS_COLORS) return; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 143 | SysColors[index] = color; |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 144 | if (SysColorBrushes[index]) |
| 145 | { |
| 146 | SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], FALSE); |
| 147 | DeleteObject( SysColorBrushes[index] ); |
| 148 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 149 | SysColorBrushes[index] = CreateSolidBrush( color ); |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 150 | SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], TRUE); |
| 151 | |
| 152 | if (SysColorPens[index]) |
| 153 | { |
| 154 | SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], FALSE); |
| 155 | DeleteObject( SysColorPens[index] ); |
| 156 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 157 | SysColorPens[index] = CreatePen( PS_SOLID, 1, color ); |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 158 | SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], TRUE); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | |
| 162 | /************************************************************************* |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 163 | * SYSCOLOR_Init |
| 164 | */ |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 165 | void SYSCOLOR_Init(void) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 166 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 167 | int i, r, g, b; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 168 | const char * const *p; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 169 | char buffer[100]; |
Gerard Patel | b7a4f46 | 1999-04-22 09:58:13 +0000 | [diff] [blame] | 170 | BOOL bOk = FALSE, bNoReg = FALSE; |
| 171 | HKEY hKey; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 172 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 173 | p = (TWEAK_WineLook == WIN31_LOOK) ? DefSysColors : DefSysColors95; |
Juergen Schmied | d0d1f15 | 1999-04-11 11:39:17 +0000 | [diff] [blame] | 174 | |
| 175 | /* first, try to read the values from the registry */ |
Marcus Meissner | 1c5777a | 1999-12-11 23:02:50 +0000 | [diff] [blame] | 176 | if (RegCreateKeyExA(HKEY_CURRENT_USER, "Control Panel\\Colors", 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) |
| 177 | bNoReg = TRUE; |
| 178 | for (i = 0; i < NUM_SYS_COLORS; i++) |
| 179 | { bOk = FALSE; |
Juergen Schmied | 4ab79f9 | 1999-04-18 09:32:38 +0000 | [diff] [blame] | 180 | |
Marcus Meissner | 1c5777a | 1999-12-11 23:02:50 +0000 | [diff] [blame] | 181 | /* first try, registry */ |
Juergen Schmied | 4ab79f9 | 1999-04-18 09:32:38 +0000 | [diff] [blame] | 182 | if (!bNoReg) |
Marcus Meissner | 1c5777a | 1999-12-11 23:02:50 +0000 | [diff] [blame] | 183 | { |
| 184 | DWORD dwDataSize = sizeof(buffer); |
| 185 | if (!(RegQueryValueExA(hKey,(LPSTR)p[i*2], 0, 0, buffer, &dwDataSize))) |
| 186 | if (sscanf( buffer, "%d %d %d", &r, &g, &b ) == 3) |
| 187 | bOk = TRUE; |
| 188 | } |
Juergen Schmied | d0d1f15 | 1999-04-11 11:39:17 +0000 | [diff] [blame] | 189 | |
Marcus Meissner | 1c5777a | 1999-12-11 23:02:50 +0000 | [diff] [blame] | 190 | /* second try, win.ini */ |
| 191 | if (!bOk) |
| 192 | { GetProfileStringA( "colors", p[i*2], p[i*2+1], buffer, 100 ); |
| 193 | if (sscanf( buffer, " %d %d %d", &r, &g, &b ) == 3) |
| 194 | bOk = TRUE; |
| 195 | } |
| 196 | |
| 197 | /* last chance, take the default */ |
| 198 | if (!bOk) |
| 199 | { int iNumColors = sscanf( p[i*2+1], " %d %d %d", &r, &g, &b ); |
| 200 | assert (iNumColors==3); |
| 201 | } |
| 202 | |
| 203 | SYSCOLOR_SetColor( i, RGB(r,g,b) ); |
| 204 | } |
| 205 | if (!bNoReg) |
| 206 | RegCloseKey(hKey); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | |
| 210 | /************************************************************************* |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 211 | * GetSysColor16 (USER.180) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 212 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 213 | COLORREF WINAPI GetSysColor16( INT16 nIndex ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 214 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 215 | return GetSysColor (nIndex); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | |
| 219 | /************************************************************************* |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 220 | * GetSysColor (USER32.289) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 221 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 222 | COLORREF WINAPI GetSysColor( INT nIndex ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 223 | { |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 224 | if (nIndex >= 0 && nIndex < NUM_SYS_COLORS) |
| 225 | return SysColors[nIndex]; |
| 226 | else |
| 227 | return 0; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 228 | } |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 229 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 230 | |
| 231 | /************************************************************************* |
| 232 | * SetSysColors16 (USER.181) |
| 233 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 234 | VOID WINAPI SetSysColors16( INT16 nChanges, const INT16 *lpSysColor, |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 235 | const COLORREF *lpColorValues ) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 236 | { |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 237 | int i; |
| 238 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 239 | for (i = 0; i < nChanges; i++) |
| 240 | { |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 241 | SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /* Send WM_SYSCOLORCHANGE message to all windows */ |
| 245 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 246 | SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 247 | |
| 248 | /* Repaint affected portions of all visible windows */ |
| 249 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 250 | RedrawWindow( GetDesktopWindow(), NULL, 0, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 251 | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | /************************************************************************* |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 256 | * SetSysColors (USER32.505) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 257 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 258 | BOOL WINAPI SetSysColors( INT nChanges, const INT *lpSysColor, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 259 | const COLORREF *lpColorValues ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 260 | { |
| 261 | int i; |
| 262 | |
| 263 | for (i = 0; i < nChanges; i++) |
| 264 | { |
| 265 | SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] ); |
| 266 | } |
| 267 | |
| 268 | /* Send WM_SYSCOLORCHANGE message to all windows */ |
| 269 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 270 | SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 271 | |
| 272 | /* Repaint affected portions of all visible windows */ |
| 273 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 274 | RedrawWindow( GetDesktopWindow(), NULL, 0, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 275 | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN ); |
| 276 | return TRUE; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 277 | } |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 278 | |
| 279 | |
| 280 | /*********************************************************************** |
| 281 | * GetSysColorBrush16 (USER.281) |
| 282 | */ |
| 283 | HBRUSH16 WINAPI GetSysColorBrush16( INT16 index ) |
| 284 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 285 | return (HBRUSH16)GetSysColorBrush(index); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | |
| 289 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 290 | * GetSysColorBrush (USER32.290) |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 291 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 292 | HBRUSH WINAPI GetSysColorBrush( INT index ) |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 293 | { |
| 294 | if (0 <= index && index < NUM_SYS_COLORS) |
| 295 | return SysColorBrushes[index]; |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 296 | WARN("Unknown index(%d)\n", index ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 297 | return GetStockObject(LTGRAY_BRUSH); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | |
| 301 | /*********************************************************************** |
| 302 | * GetSysColorPen16 (Not a Windows API) |
| 303 | */ |
| 304 | HPEN16 WINAPI GetSysColorPen16( INT16 index ) |
| 305 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 306 | return (HPEN16)GetSysColorPen(index); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | |
| 310 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 311 | * GetSysColorPen (Not a Windows API) |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 312 | * |
| 313 | * This function is new to the Wine lib -- it does not exist in |
| 314 | * Windows. However, it is a natural complement for GetSysColorBrush |
| 315 | * in the Win32 API and is needed quite a bit inside Wine. |
| 316 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 317 | HPEN WINAPI GetSysColorPen( INT index ) |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 318 | { |
| 319 | /* We can assert here, because this function is internal to Wine */ |
| 320 | assert (0 <= index && index < NUM_SYS_COLORS); |
| 321 | return SysColorPens[index]; |
| 322 | |
| 323 | } |