Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
14 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include "shmgdefs.h"
  4. #undef COLOR_MAX
  5. #define COLOR_MAX (COLOR_GRADIENTINACTIVECAPTION + 1)
  6. #define COLOR_MAX_NT4 (COLOR_INFOBK + 1)
  7. #define SCHEME_MAX 27
  8. CONST TCHAR* rgpszSchemes[SCHEME_MAX] = {
  9. TEXT("High Contrast Black (EL)"), // 0
  10. TEXT("High Contrast White (EL)"), // 1
  11. TEXT("Brick"), // 2
  12. TEXT("Desert"), // 3
  13. TEXT("Eggplant"), // 4
  14. TEXT("High Contrast Black"), // 5
  15. TEXT("High Contrast White"), // 6
  16. TEXT("Lilac"), // 7
  17. TEXT("Marine (HC)"), // 8
  18. TEXT("Plum (HC)"), // 9
  19. TEXT("Pumpkin (L)"), // 10
  20. TEXT("Rainy Day"), // 11
  21. TEXT("Red, White, and Blue (VGA)"), // 12
  22. TEXT("Rose"), // 13
  23. TEXT("Slate"), // 14
  24. TEXT("Spruce"), // 15
  25. TEXT("Storm (VGA)"), // 16
  26. TEXT("Teal (VGA)"), // 17
  27. TEXT("Windows Standard"), // 18
  28. TEXT("Rose (large)"), // 19
  29. TEXT("High Contrast Black (L)"), // 20
  30. TEXT("High Contrast White (L)"), // 21
  31. TEXT("Lilac (large)"), // 22
  32. TEXT("Windows Standard (EL)"), // 23
  33. TEXT("Windows Standard (L)"), // 24
  34. TEXT("Maple"), // 25
  35. TEXT("Wheat)") // 26
  36. };
  37. CONST TCHAR* rgpsz[COLOR_MAX] = {
  38. TEXT("Scrollbar"),
  39. TEXT("Background"),
  40. TEXT("ActiveTitle"),
  41. TEXT("InactiveTitle"),
  42. TEXT("Menu"),
  43. TEXT("Window"),
  44. TEXT("WindowFrame"),
  45. TEXT("MenuText"),
  46. TEXT("WindowText"),
  47. TEXT("TitleText"),
  48. TEXT("ActiveBorder"),
  49. TEXT("InactiveBorder"),
  50. TEXT("AppWorkspace"),
  51. TEXT("Hilight"),
  52. TEXT("HilightText"),
  53. TEXT("ButtonFace"),
  54. TEXT("ButtonShadow"),
  55. TEXT("GrayText"),
  56. TEXT("ButtonText"),
  57. TEXT("InactiveTitleText"),
  58. TEXT("ButtonHilight"),
  59. TEXT("ButtonDkShadow"),
  60. TEXT("ButtonLight"),
  61. TEXT("InfoText"),
  62. TEXT("InfoWindow"),
  63. TEXT("ButtonAlternateFace"),
  64. TEXT("HotTracking"),
  65. TEXT("GradientActiveTitle"),
  66. TEXT("GradientInactiveTitle")
  67. };
  68. COLORREF rgcr[SCHEME_MAX][COLOR_MAX] = {
  69. {0x02000000,0x02000000,0x02800080,0x02008000,0x02000000,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x0200FFFF,0x02008000,0x02000000,0x02800080,0x02FFFFFF,0x02000000,0x02808080,0x0200FF00,0x02FFFFFF,0x02FFFFFF,0x02C0C0C0,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x02800080,0x02800080,0x02800080,0x02008000},
  70. {0x02FFFFFF,0x02FFFFFF,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02808080,0x02C0C0C0,0x02808080,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02808080,0x0200FF00,0x02000000,0x02000000,0x02C0C0C0,0x02000000,0x02C0C0C0,0x02000000,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF},
  71. {0x02D2E0E1,0x00000042,0x02000080,0x0261898D,0x02A5BFC2,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02D2E0E1,0x02A5BFC2,0x02A5BFC2,0x02D2E0E1,0x0261898D,0x02FFFFFF,0x02A5BFC2,0x0261898D,0x0261898D,0x02000000,0x02D2E0E1,0x02D2E0E1,0x02000000,0x02A5BFC2,0x02000080,0x02D2E0E1,0x00C0C0C0,0x02000080,0x004074B0,0x0270B8C8},
  72. {0x02DDE6EA,0x02688DA2,0x02808000,0x02688DA2,0x02BBCCD5,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02BBCCD5,0x02BBCCD5,0x02688DA2,0x02808000,0x02FFFFFF,0x02BBCCD5,0x02688DA2,0x02688DA2,0x02000000,0x02FFFFFF,0x02DDE6EA,0x02000000,0x02BBCCD5,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02808000,0x00AABD84,0x0280D0E8},
  73. {0x02A8B090,0x00400040,0x02788058,0x02A8B090,0x02A8B090,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02A8B090,0x02A8B090,0x02808080,0x02788058,0x02FFFFFF,0x02A8B090,0x02788058,0x02788058,0x02000000,0x02788058,0x02D8D8C8,0x02000000,0x02A8B090,0x02800080,0x02FFFFFF,0x00C0C0C0,0x02788058,0x00834B83,0x00D2BDCB},
  74. {0x02000000,0x02000000,0x02800080,0x02008000,0x02000000,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x0200FFFF,0x02008000,0x02000000,0x02800080,0x02FFFFFF,0x02000000,0x02808080,0x0200FF00,0x02FFFFFF,0x02FFFFFF,0x02C0C0C0,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x00C0C0C0,0x02800080,0x02D88CC8,0x0012B42B},
  75. {0x02FFFFFF,0x02FFFFFF,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02808080,0x02C0C0C0,0x02808080,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02808080,0x0200FF00,0x02000000,0x02000000,0x02C0C0C0,0x02000000,0x02C0C0C0,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02000000,0x02A09CA0,0x02D8D4D8},
  76. {0x02D9A8AE,0x02000000,0x02B14E5A,0x02808080,0x02D9A8AE,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02D9A8AE,0x02D9A8AE,0x02B14E5A,0x02B14E5A,0x02FFFFFF,0x02D9A8AE,0x02B14E5A,0x02B14E5A,0x02000000,0x02FFFFFF,0x02ECD5D8,0x02000000,0x02D9A8AE,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02B14E5A,0x02CB8FB6,0x02D0B4B8},
  77. {0x02D8E0C8,0x00474E2C,0x02800000,0x02889048,0x02B8C088,0x02D8E0C8,0x02000000,0x02000000,0x02000000,0x02C0C0C0,0x02B8C088,0x02B8C088,0x00848D4B,0x02800000,0x02FFFFFF,0x02B8C088,0x02889048,0x02889048,0x02000000,0x02C0C0C0,0x02D8E0C8,0x02000000,0x02B8C088,0x02000000,0x02D8E0C8,0x00C0C0C0,0x02800000,0x02C0B418,0x02D8CC78},
  78. {0x00C8D0D8,0x00402840,0x00604048,0x00586078,0x009098A8,0x00C8D0D8,0x00000000,0x00000000,0x00000000,0x00C8D0D8,0x009098A8,0x009098A8,0x005A6374,0x00484828,0x00C8D0D8,0x009098A8,0x00586078,0x00586078,0x00000000,0x009098A8,0x00C8D0D8,0x00000000,0x009098A8,0x00580030,0x00C8CCD5,0x00C0C0C0,0x00604048,0x00B884A0,0x007898A8},
  79. {0x02CFEAF5,0x00420042,0x022FA5D7,0x02A4A0A0,0x029DD5EC,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x029DD5EC,0x029DD5EC,0x02CFEAF5,0x02800080,0x02FFFFFF,0x029DD5EC,0x022FA5D7,0x022FA5D7,0x02000000,0x02CFEAF5,0x02CFEAF5,0x02000000,0x029DD5EC,0x02800080,0x02FFFFFF,0x00C0C0C0,0x022FA5D7,0x0288CCE0,0x0290CCD0},
  80. {0x02D9CCC1,0x02000000,0x027D654F,0x02808080,0x02B19983,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02B19983,0x02B19983,0x02808080,0x027D654F,0x02FFFFFF,0x02B19983,0x027D654F,0x027D654F,0x02000000,0x02D9CCC1,0x02D9CCC1,0x02000000,0x02B19983,0x02000000,0x02FFFFFF,0x00C0C0C0,0x027D654F,0x02D0B480,0x02D0BCB0},
  81. {0x02C0C0C0,0x00420000,0x02000080,0x02808080,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02C0C0C0,0x02FFFFFF,0x02000080,0x02FFFFFF,0x02C0C0C0,0x02808080,0x02808080,0x02000000,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02C0C0C0,0x02800000,0x02FFFFFF,0x00C0C0C0,0x02000080,0x02A81000,0x00C9BEBA},
  82. {0x02B7AFCF,0x02808080,0x0270609F,0x02A4A0A0,0x02B7AFCF,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02B7AFCF,0x02B7AFCF,0x0270609F,0x0270609F,0x02FFFFFF,0x02B7AFCF,0x0270609F,0x0270609F,0x02000000,0x02000000,0x02DCD8E7,0x02000000,0x02B7AFCF,0x02000000,0x02FFFFFF,0x00C0C0C0,0x0270609F,0x02D0CCD8,0x02D0D4D0},
  83. {0x02E3DCCE,0x00414141,0x02978055,0x02808080,0x02C8B99D,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C8B99D,0x02C8B99D,0x00424242,0x02978055,0x02FFFFFF,0x02C8B99D,0x02978055,0x02978055,0x02000000,0x02C0C0C0,0x02E3DCCE,0x02000000,0x02C8B99D,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02978055,0x02D8B888,0x02C8BCA0},
  84. {0x02D3E3D0,0x00213F21,0x02649759,0x02808080,0x02A9C8A2,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02A9C8A2,0x02A9C8A2,0x02D3E3D0,0x02649759,0x02FFFFFF,0x02A9C8A2,0x02649759,0x02649759,0x02000000,0x02D3E3D0,0x02D3E3D0,0x02000000,0x02A9C8A2,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02649759,0x02E8C898,0x02B0CCA8},
  85. {0x02C0C0C0,0x02000000,0x02800080,0x02808080,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02C0C0C0,0x02808080,0x02800080,0x02FFFFFF,0x02C0C0C0,0x02808080,0x02808080,0x02000000,0x02000000,0x02FFFFFF,0x02000000,0x02C0C0C0,0x02800080,0x02FFFFFF,0x00C0C0C0,0x02800080,0x02B08C38,0x02A8ACA8},
  86. {0x02C0C0C0,0x00404000,0x02808000,0x02808080,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02C0C0C0,0x02808080,0x02808000,0x02FFFFFF,0x02C0C0C0,0x02808080,0x02808080,0x02000000,0x02F0FBFF,0x02FFFFFF,0x02000000,0x02C0C0C0,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02808000,0x00D8CC00,0x02B8C898},
  87. {0x00C0C0C0,0x00808000,0x00800000,0x00808080,0x00C0C0C0,0x00FFFFFF,0x00000000,0x00000000,0x00000000,0x00FFFFFF,0x00C0C0C0,0x00C0C0C0,0x00808080,0x00800000,0x00FFFFFF,0x00C0C0C0,0x00808080,0x00808080,0x00000000,0x00C0C0C0,0x00FFFFFF,0x00000000,0x00C0C0C0,0x00000000,0x00E1FFFF,0x00C0C0C0,0x00800000,0x00D08410,0x00B5B5B5},
  88. {0x02C0C0C0,0x02808080,0x027060A0,0x02A4A0A0,0x02B8B0D0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02B8B0D0,0x02B8B0D0,0x02E0D8E8,0x027060A0,0x02FFFFFF,0x02B8B0D0,0x027060A0,0x027060A0,0x02000000,0x027D7D7D,0x02E0D8E8,0x02000000,0x02B8B0D0,0x02000000,0x02FFFFFF,0x00C0C0C0,0x027060A0,0x02D0CCD8,0x02D0D4D0},
  89. {0x02000000,0x02000000,0x02800080,0x02008000,0x02000000,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x0200FFFF,0x02008000,0x02000000,0x02800080,0x02FFFFFF,0x02000000,0x02808080,0x0200FF00,0x02FFFFFF,0x02FFFFFF,0x02C0C0C0,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x00C0C0C0,0x02800080,0x00800080,0x00008000},
  90. {0x02FFFFFF,0x02FFFFFF,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02808080,0x02C0C0C0,0x02808080,0x02000000,0x02FFFFFF,0x02FFFFFF,0x02808080,0x0200FF00,0x02000000,0x02000000,0x02C0C0C0,0x02000000,0x02C0C0C0,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02000000,0x00000000,0x00FFFFFF},
  91. {0x02D9A8AE,0x02000000,0x02B14E5A,0x02808080,0x02D9A8AE,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02D9A8AE,0x02D9A8AE,0x02B14E5A,0x02B14E5A,0x02FFFFFF,0x02D9A8AE,0x02B14E5A,0x02B14E5A,0x02000000,0x02FFFFFF,0x02ECD5D8,0x02000000,0x02D9A8AE,0x02000000,0x02FFFFFF,0x00C0C0C0,0x02B14E5A,0x02CB8FB6,0x02D0B4B8},
  92. {0x02C0C0C0,0x02808000,0x02800000,0x02808080,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02C0C0C0,0x02808080,0x02800000,0x02FFFFFF,0x02C0C0C0,0x02808080,0x02808080,0x02000000,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02DFDFDF,0x02000000,0x00E1FFFF,0x00C0C0C0,0x02800000,0x02D08410,0x02B5B5B5},
  93. {0x02C0C0C0,0x02808000,0x02800000,0x02808080,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02C0C0C0,0x02808080,0x02800000,0x02FFFFFF,0x02C0C0C0,0x02808080,0x02808080,0x02000000,0x02C0C0C0,0x02FFFFFF,0x02000000,0x02DFDFDF,0x02000000,0x02E1FFFF,0x00C0C0C0,0x02800000,0x02D08410,0x02B5B5B5},
  94. {0x02D7ECF2,0x02000000,0x0246A6C6,0x02A4A0A0,0x02AED8E6,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02AED8E6,0x02AED8E6,0x02D7ECF2,0x0246A6C6,0x02000000,0x02AED8E6,0x0246A6C6,0x0246A6C6,0x02000000,0x02D7ECF2,0x02D7ECF2,0x02000000,0x02AED8E6,0x02000000,0x02FFFFFF,0x02C0C0C0,0x0246A6C6,0x02389CC0,0x0288C8E0},
  95. {0x02D0EEEE,0x021D4000,0x02008080,0x0241BCBC,0x02A0DEDE,0x02FFFFFF,0x02000000,0x02000000,0x02000000,0x02FFFFFF,0x02A0DEDE,0x02A0DEDE,0x02D0EEEE,0x02008080,0x02FFFFFF,0x02A0DEDE,0x0241BCBC,0x0241BCBC,0x02000000,0x02FFFFFF,0x02D0EEEE,0x02000000,0x02A0DEDE,0x02000000,0x02FFFFFF,0x02C0C0C0,0x02008080,0x0248B0C8,0x0280B8B8},
  96. };
  97. void SetColor(HKEY hkey, int iColor, COLORREF cr)
  98. {
  99. TCHAR sz[16];
  100. wsprintf(sz, TEXT("%d %d %d"), GetRValue(cr), GetGValue(cr), GetBValue(cr));
  101. RegSetValueEx(hkey, rgpsz[iColor], 0, REG_SZ, (LPBYTE)sz, (wcslen(sz) + 1) * sizeof(TCHAR));
  102. }
  103. void SetGradient(HKEY hkey, int iScheme)
  104. {
  105. SetColor(hkey, COLOR_GRADIENTACTIVECAPTION, rgcr[iScheme][COLOR_GRADIENTACTIVECAPTION]);
  106. SetColor(hkey, COLOR_GRADIENTINACTIVECAPTION, rgcr[iScheme][COLOR_GRADIENTINACTIVECAPTION]);
  107. }
  108. void SetDesktop(HKEY hkey)
  109. {
  110. SetColor(hkey, COLOR_DESKTOP, 0x00A56E3A);
  111. }
  112. #if DBG
  113. #define DebugOut fwprintf
  114. #else
  115. #define DebugOut
  116. #endif
  117. void FixGradientColors(void)
  118. {
  119. COLORREF cr, rgcrCurrent[COLOR_MAX] = {0x00C0C0C0,0x00808000,0x00800000,0x00808080,0x00C0C0C0,0x00FFFFFF,0x00000000,0x00000000,0x00000000,0x00FFFFFF,0x00C0C0C0,0x00C0C0C0,0x00808080,0x00800000,0x00FFFFFF,0x00C0C0C0,0x00808080,0x00808080,0x00000000,0x00C0C0C0,0x00FFFFFF,0x00000000,0x00C0C0C0,0x00000000,0x00E1FFFF,0x00C0C0C0,0x00800000,0x00800000,0x00808080};
  120. HKEY hkey;
  121. DWORD dwSize;
  122. int i, j;
  123. TCHAR szColor[16];
  124. DWORD dwR, dwG, dwB;
  125. if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0,
  126. KEY_READ | KEY_SET_VALUE | KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
  127. RegDeleteValue(hkey, TEXT("UserPreferencesMask"));
  128. RegCloseKey(hkey);
  129. }
  130. if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0, KEY_READ | KEY_SET_VALUE | KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS)
  131. return;
  132. for (i = 0; i < sizeof(rgpsz) / sizeof(rgpsz[0]); i++) {
  133. dwSize = sizeof(szColor) * sizeof(TCHAR);
  134. if (RegQueryValueEx(hkey, rgpsz[i], NULL, NULL, (LPBYTE)szColor, &dwSize) == ERROR_SUCCESS) {
  135. swscanf(szColor, TEXT("%d %d %d"), &dwR, &dwG, &dwB);
  136. rgcrCurrent[i] = RGB(dwR, dwG, dwB);
  137. }
  138. }
  139. for (i = 0; i < SCHEME_MAX; i++) {
  140. for (j = 0; j < COLOR_MAX_NT4; j++) {
  141. cr = (rgcr[i][j] & 0x00FFFFFF);
  142. if (rgcrCurrent[j] != cr) {
  143. break;
  144. }
  145. }
  146. if (j == COLOR_MAX_NT4) {
  147. break;
  148. }
  149. }
  150. if (j == COLOR_MAX_NT4) {
  151. DebugOut(stderr, TEXT("Upgrading NT4 color scheme %s\n"), rgpszSchemes[i]);
  152. SetGradient(hkey, i);
  153. /*
  154. * For Windows Standard, WS EL, WS L, update the desktop color.
  155. */
  156. if (i == 18 || i == 23 || i == 24) {
  157. DebugOut(stderr, TEXT("Updating %s desktop color\n"), rgpszSchemes[i]);
  158. SetDesktop(hkey);
  159. }
  160. } else {
  161. DebugOut(stderr, TEXT("No matching NT4 scheme found\n"));
  162. }
  163. RegCloseKey(hkey);
  164. }