Leaked source code of windows server 2003
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.

635 lines
21 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #ifndef _INC_SCHEMES_H
  3. #define _INC_SCHEMES_H
  4. // HACK - THESE VALUES ARE HARD CODED
  5. #define COLOR_MAX_95_NT4 25
  6. #if(WINVER >= 0x0501)
  7. #define COLOR_MAX_97_NT5 31
  8. #elif(WINVER == 0x0500)
  9. #define COLOR_MAX_97_NT5 29
  10. #else
  11. #define COLOR_MAX_97_NT5 25
  12. #endif
  13. #define MAX_THEME_SZ 512
  14. #define MAX_NUM_SZ 20
  15. #define DEF_SPACING 43 // default horizontal and vertical icon spacing
  16. #define CONTROL_PANEL_DESKTOP TEXT("Control Panel\\Desktop")
  17. #define CURSOR_BLINK_RATE TEXT("CursorBlinkRate")
  18. #define DEFAULT_BLINK_RATE 530
  19. DWORD WINAPI RegQueryStrDW(DWORD dwDefault, HKEY hkey, LPTSTR lpSubKey, LPTSTR lpValueName);
  20. BOOL RegSetStrDW(HKEY hkey, LPTSTR lpSection, LPCTSTR lpKeyName, DWORD dwValue);
  21. #include "resource.h"
  22. #include "CurSchme.h"
  23. // Specify all external variables
  24. extern PTSTR s_pszColorNames[]; // JMC: HACK
  25. extern TCHAR g_szColors[]; // = TEXT("colors"); // colors section name
  26. // Location of the Colors subkey in Registry; Defined in RegStr.h
  27. extern TCHAR szRegStr_Colors[]; // = REGSTR_PATH_COLORS;
  28. extern TCHAR g_winScheme[];
  29. // Scheme data used locally by this app - NOTE: This structure
  30. // does NOT use or need the A and W forms for its members. The other schemedata's
  31. // MUST use the A and W forms since that's how they are stored in the registry
  32. typedef struct {
  33. int nNameStringId; // the rid of the name of the color scheme
  34. TCHAR szNameIndexId[MAX_NUM_SZ]; // the index into HKCU\Control Panel\Appearance\New Schemes
  35. int nColorsUsed;
  36. COLORREF rgb[COLOR_MAX_97_NT5];
  37. } SCHEMEDATALOCAL;
  38. struct PORTABLE_NONCLIENTMETRICS
  39. {
  40. // Non-ClientMetric storage area
  41. int m_iBorderWidth;
  42. int m_iScrollWidth;
  43. int m_iScrollHeight;
  44. int m_iCaptionWidth;
  45. int m_iCaptionHeight;
  46. int m_lfCaptionFont_lfHeight;
  47. int m_lfCaptionFont_lfWeight;
  48. int m_iSmCaptionWidth;
  49. int m_iSmCaptionHeight;
  50. int m_lfSmCaptionFont_lfHeight;
  51. int m_lfSmCaptionFont_lfWeight;
  52. int m_iMenuWidth;
  53. int m_iMenuHeight;
  54. int m_lfMenuFont_lfHeight;
  55. int m_lfMenuFont_lfWeight;
  56. int m_lfStatusFont_lfHeight;
  57. int m_lfStatusFont_lfWeight;
  58. int m_lfMessageFont_lfHeight;
  59. int m_lfMessageFont_lfWeight;
  60. int m_lfIconWindowsDefault_lfHeight;
  61. int m_lfIconWindowsDefault_lfWeight;
  62. int m_nFontFaces; // 0 = NoChanges, 1 = Use WindowsDefault font face
  63. void SetToWindowsDefault()
  64. {
  65. m_nFontFaces = 1;
  66. int rgnValues[MAX_DISTINCT_VALUES];
  67. int nCountValues;
  68. LoadArrayFromStringTable(IDS_WINDOWSDEFAULTSIZES, rgnValues, &nCountValues);
  69. _ASSERTE(21 == nCountValues);
  70. if(21 != nCountValues)
  71. {
  72. // Below is the hard-coded defaults for the window metrics
  73. m_iBorderWidth = 1;
  74. m_iScrollWidth = 16;
  75. m_iScrollHeight = 16;
  76. m_iCaptionWidth = 18;
  77. m_iCaptionHeight = 18;
  78. m_lfCaptionFont_lfHeight = -11;
  79. m_lfCaptionFont_lfWeight = 700;
  80. m_iSmCaptionWidth = 15;
  81. m_iSmCaptionHeight = 15;
  82. m_lfSmCaptionFont_lfHeight = -11;
  83. m_lfSmCaptionFont_lfWeight = 700;
  84. m_iMenuWidth = 18;
  85. m_iMenuHeight = 18;
  86. m_lfMenuFont_lfHeight = -11;
  87. m_lfMenuFont_lfWeight = 400;
  88. m_lfStatusFont_lfHeight = -11;
  89. m_lfStatusFont_lfWeight = 400;
  90. m_lfMessageFont_lfHeight = -11;
  91. m_lfMessageFont_lfWeight = 400;
  92. m_lfIconWindowsDefault_lfHeight = -11;
  93. m_lfIconWindowsDefault_lfWeight = 400;
  94. }
  95. else
  96. {
  97. m_iBorderWidth = rgnValues[0];
  98. m_iScrollWidth = rgnValues[1];
  99. m_iScrollHeight = rgnValues[2];
  100. m_iCaptionWidth = rgnValues[3];
  101. m_iCaptionHeight = rgnValues[4];
  102. m_lfCaptionFont_lfHeight = rgnValues[5];
  103. m_lfCaptionFont_lfWeight = rgnValues[6];
  104. m_iSmCaptionWidth = rgnValues[7];
  105. m_iSmCaptionHeight = rgnValues[8];
  106. m_lfSmCaptionFont_lfHeight = rgnValues[9];
  107. m_lfSmCaptionFont_lfWeight = rgnValues[10];
  108. m_iMenuWidth = rgnValues[11];
  109. m_iMenuHeight = rgnValues[12];
  110. m_lfMenuFont_lfHeight = rgnValues[13];
  111. m_lfMenuFont_lfWeight = rgnValues[14];
  112. m_lfStatusFont_lfHeight = rgnValues[15];
  113. m_lfStatusFont_lfWeight = rgnValues[16];
  114. m_lfMessageFont_lfHeight = rgnValues[17];
  115. m_lfMessageFont_lfWeight = rgnValues[18];
  116. m_lfIconWindowsDefault_lfHeight = rgnValues[19];
  117. m_lfIconWindowsDefault_lfWeight = rgnValues[20];
  118. }
  119. }
  120. void LoadOriginal()
  121. {
  122. NONCLIENTMETRICS ncmTemp;
  123. LOGFONT lfIcon;
  124. GetNonClientMetrics(&ncmTemp, &lfIcon);
  125. m_iBorderWidth = ncmTemp.iBorderWidth;
  126. m_iScrollWidth = ncmTemp.iScrollWidth;
  127. m_iScrollHeight = ncmTemp.iScrollHeight;
  128. m_iCaptionWidth = ncmTemp.iCaptionWidth;
  129. m_iCaptionHeight = ncmTemp.iCaptionHeight;
  130. m_lfCaptionFont_lfHeight = ncmTemp.lfCaptionFont.lfHeight;
  131. m_lfCaptionFont_lfWeight = ncmTemp.lfCaptionFont.lfWeight;
  132. m_iSmCaptionWidth = ncmTemp.iSmCaptionWidth;
  133. m_iSmCaptionHeight = ncmTemp.iSmCaptionHeight;
  134. m_lfSmCaptionFont_lfHeight = ncmTemp.lfSmCaptionFont.lfHeight;
  135. m_lfSmCaptionFont_lfWeight = ncmTemp.lfSmCaptionFont.lfWeight;
  136. m_iMenuWidth = ncmTemp.iMenuWidth;
  137. m_iMenuHeight = ncmTemp.iMenuHeight;
  138. m_lfMenuFont_lfHeight = ncmTemp.lfMenuFont.lfHeight;
  139. m_lfMenuFont_lfWeight = ncmTemp.lfMenuFont.lfWeight;
  140. m_lfStatusFont_lfHeight = ncmTemp.lfStatusFont.lfHeight;
  141. m_lfStatusFont_lfWeight = ncmTemp.lfStatusFont.lfWeight;
  142. m_lfMessageFont_lfHeight = ncmTemp.lfMessageFont.lfHeight;
  143. m_lfMessageFont_lfWeight = ncmTemp.lfMessageFont.lfWeight;
  144. m_lfIconWindowsDefault_lfHeight = lfIcon.lfHeight;
  145. m_lfIconWindowsDefault_lfWeight = lfIcon.lfWeight;
  146. m_nFontFaces = 0;
  147. }
  148. void ApplyChanges() const;
  149. };
  150. struct WIZSCHEME
  151. {
  152. WIZSCHEME()
  153. {
  154. ZeroMemory(this, sizeof(*this));
  155. m_cbSize = sizeof(*this);
  156. m_dwVersion = 0x000000FF;
  157. ClearTheme();
  158. ClearWallpaper();
  159. m_nSelectedSize = -1;
  160. m_szSelectedStyle[0] = 0;
  161. }
  162. DWORD m_cbSize;
  163. DWORD m_dwVersion;
  164. COLORREF m_rgb[COLOR_MAX_97_NT5];
  165. void LoadOriginal();
  166. FILTERKEYS m_FILTERKEYS;
  167. MOUSEKEYS m_MOUSEKEYS;
  168. STICKYKEYS m_STICKYKEYS;
  169. TOGGLEKEYS m_TOGGLEKEYS;
  170. SOUNDSENTRY m_SOUNDSENTRY;
  171. ACCESSTIMEOUT m_ACCESSTIMEOUT;
  172. // SERIALKEYS m_SERIALKEYS;
  173. BOOL m_bShowSounds;
  174. BOOL m_bShowExtraKeyboardHelp;
  175. BOOL m_bSwapMouseButtons;
  176. int m_nMouseTrails;
  177. int m_nMouseSpeed;
  178. int m_nIconSize;
  179. int m_nCursorScheme;
  180. // int m_nScrollWidth;
  181. // int m_nBorderWidth;
  182. PORTABLE_NONCLIENTMETRICS m_PortableNonClientMetrics;
  183. #ifdef _DEBUG
  184. void Dump()
  185. {
  186. FILE *pStream = fopen( "c:\\txt.acw", "w" );
  187. if(pStream)
  188. {
  189. for(int i=0;i<COLOR_MAX_97_NT5;i++)
  190. fprintf(pStream, "m_rgb[%2i] = RGB(%3i,%3i,%3i);\r\n", i, GetRValue(m_rgb[i]), GetGValue(m_rgb[i]), GetBValue(m_rgb[i]));
  191. #define TEMP_MAC(xxx, yyy) fprintf(pStream, "m_" #xxx "." #yyy " = %i;\r\n", m_##xxx.yyy)
  192. TEMP_MAC(FILTERKEYS, cbSize);
  193. TEMP_MAC(FILTERKEYS, dwFlags);
  194. TEMP_MAC(FILTERKEYS, iWaitMSec);
  195. TEMP_MAC(FILTERKEYS, iDelayMSec);
  196. TEMP_MAC(FILTERKEYS, iRepeatMSec);
  197. TEMP_MAC(FILTERKEYS, iBounceMSec);
  198. TEMP_MAC(MOUSEKEYS, cbSize);
  199. TEMP_MAC(MOUSEKEYS, dwFlags);
  200. TEMP_MAC(MOUSEKEYS, iMaxSpeed);
  201. TEMP_MAC(MOUSEKEYS, iTimeToMaxSpeed);
  202. TEMP_MAC(MOUSEKEYS, iCtrlSpeed);
  203. TEMP_MAC(MOUSEKEYS, dwReserved1);
  204. TEMP_MAC(MOUSEKEYS, dwReserved2);
  205. TEMP_MAC(STICKYKEYS, cbSize);
  206. TEMP_MAC(STICKYKEYS, dwFlags);
  207. TEMP_MAC(TOGGLEKEYS, cbSize);
  208. TEMP_MAC(TOGGLEKEYS, dwFlags);
  209. TEMP_MAC(SOUNDSENTRY, cbSize);
  210. TEMP_MAC(SOUNDSENTRY, dwFlags);
  211. TEMP_MAC(SOUNDSENTRY, iFSTextEffect);
  212. TEMP_MAC(SOUNDSENTRY, iFSTextEffectMSec);
  213. TEMP_MAC(SOUNDSENTRY, iFSTextEffectColorBits);
  214. TEMP_MAC(SOUNDSENTRY, iFSGrafEffect);
  215. TEMP_MAC(SOUNDSENTRY, iFSGrafEffectMSec);
  216. TEMP_MAC(SOUNDSENTRY, iFSGrafEffectColor);
  217. TEMP_MAC(SOUNDSENTRY, iWindowsEffect);
  218. TEMP_MAC(SOUNDSENTRY, iWindowsEffectMSec);
  219. TEMP_MAC(SOUNDSENTRY, lpszWindowsEffectDLL);
  220. TEMP_MAC(SOUNDSENTRY, iWindowsEffectOrdinal);
  221. TEMP_MAC(ACCESSTIMEOUT, cbSize);
  222. TEMP_MAC(ACCESSTIMEOUT, dwFlags);
  223. TEMP_MAC(ACCESSTIMEOUT, iTimeOutMSec);
  224. #define TEMP_MAC2(xxx) fprintf(pStream, #xxx " = %i;\r\n", xxx)
  225. TEMP_MAC2(m_bShowSounds);
  226. TEMP_MAC2(m_bShowExtraKeyboardHelp);
  227. TEMP_MAC2(m_bSwapMouseButtons);
  228. TEMP_MAC2(m_nMouseTrails);
  229. TEMP_MAC2(m_nMouseSpeed);
  230. TEMP_MAC2(m_nIconSize);
  231. TEMP_MAC2(m_nCursorScheme);
  232. NONCLIENTMETRICS ncm;
  233. LOGFONT lf;
  234. GetNonClientMetrics(&ncm, &lf);
  235. #define TEMP_MAC3(xxx) fprintf(pStream, "m_ncmWindowsDefault." #xxx " = %i;\n", ncm.xxx)
  236. #define TEMP_MAC4(xxx) fprintf(pStream, "m_ncmWindowsDefault." #xxx ".lfHeight = %i;\nm_ncmWindowsDefault." #xxx ".lfWeight = %i;\n", ncm.xxx.lfHeight, ncm.xxx.lfWeight)
  237. TEMP_MAC3(cbSize);
  238. TEMP_MAC3(iBorderWidth);
  239. TEMP_MAC3(iScrollWidth);
  240. TEMP_MAC3(iScrollHeight);
  241. TEMP_MAC3(iCaptionWidth);
  242. TEMP_MAC3(iCaptionHeight);
  243. TEMP_MAC4(lfCaptionFont);
  244. TEMP_MAC3(iSmCaptionWidth);
  245. TEMP_MAC3(iSmCaptionHeight);
  246. TEMP_MAC4(lfSmCaptionFont);
  247. TEMP_MAC3(iMenuWidth);
  248. TEMP_MAC3(iMenuHeight);
  249. TEMP_MAC4(lfMenuFont);
  250. TEMP_MAC4(lfStatusFont);
  251. TEMP_MAC4(lfMessageFont);
  252. fprintf(pStream, "m_lfIconWindowsDefault.lfHeight = %i;\nm_lfIconWindowsDefault.lfWeight = %i;\n", lf.lfHeight, lf.lfWeight);
  253. // Print for string table
  254. #undef TEMP_MAC3
  255. #undef TEMP_MAC4
  256. #define TEMP_MAC3(xxx) fprintf(pStream, "%i ", ncm.xxx)
  257. #define TEMP_MAC4(xxx) fprintf(pStream, "%i %i ", ncm.xxx.lfHeight, ncm.xxx.lfWeight)
  258. TEMP_MAC3(cbSize);
  259. TEMP_MAC3(iBorderWidth);
  260. TEMP_MAC3(iScrollWidth);
  261. TEMP_MAC3(iScrollHeight);
  262. TEMP_MAC3(iCaptionWidth);
  263. TEMP_MAC3(iCaptionHeight);
  264. TEMP_MAC4(lfCaptionFont);
  265. TEMP_MAC3(iSmCaptionWidth);
  266. TEMP_MAC3(iSmCaptionHeight);
  267. TEMP_MAC4(lfSmCaptionFont);
  268. TEMP_MAC3(iMenuWidth);
  269. TEMP_MAC3(iMenuHeight);
  270. TEMP_MAC4(lfMenuFont);
  271. TEMP_MAC4(lfStatusFont);
  272. TEMP_MAC4(lfMessageFont);
  273. fprintf(pStream, "%i %i\n", lf.lfHeight, lf.lfWeight);
  274. fclose(pStream);
  275. }
  276. }
  277. #endif
  278. void SetToWindowsDefault()
  279. {
  280. m_rgb[ 0] = RGB(212,208,200); //192,192,192
  281. m_rgb[ 1] = RGB( 58,110,165);
  282. m_rgb[ 2] = RGB( 10, 36,106); // 0,0,128
  283. m_rgb[ 3] = RGB(128,128,128);
  284. m_rgb[ 4] = RGB(212,208,200); //192,192,192
  285. m_rgb[ 5] = RGB(255,255,255);
  286. m_rgb[ 6] = RGB( 0, 0, 0);
  287. m_rgb[ 7] = RGB( 0, 0, 0);
  288. m_rgb[ 8] = RGB( 0, 0, 0);
  289. m_rgb[ 9] = RGB(255,255,255);
  290. m_rgb[10] = RGB(212,208,200); //192,192,192
  291. m_rgb[11] = RGB(212,208,200); //192,192,192
  292. m_rgb[12] = RGB(128,128,128);
  293. m_rgb[13] = RGB( 10, 36,106); // 0,0,128
  294. m_rgb[14] = RGB(255,255,255);
  295. m_rgb[15] = RGB(212,208,200); //192,192,192
  296. m_rgb[16] = RGB(128,128,128);
  297. m_rgb[17] = RGB(128,128,128);
  298. m_rgb[18] = RGB( 0, 0, 0);
  299. m_rgb[19] = RGB(212,208,200); //192,192,192
  300. m_rgb[20] = RGB(255,255,255);
  301. m_rgb[21] = RGB( 81, 81, 75); // 0,0,0
  302. m_rgb[22] = RGB(236,234,231); // 192,192,192
  303. m_rgb[23] = RGB( 0, 0, 0);
  304. m_rgb[24] = RGB(255,255,225);
  305. m_rgb[25] = RGB(181,181,181); // button alternate face
  306. m_rgb[26] = RGB( 0, 0,128);
  307. m_rgb[27] = RGB( 166,202,240); // 16,132,208
  308. m_rgb[28] = RGB(192,192,192); // 181,181,181
  309. ClearTheme();
  310. ClearWallpaper();
  311. m_FILTERKEYS.cbSize = 24;
  312. m_FILTERKEYS.dwFlags = 126;
  313. m_FILTERKEYS.iWaitMSec = 1000;
  314. m_FILTERKEYS.iDelayMSec = 1000; //500
  315. m_FILTERKEYS.iRepeatMSec = 500; //1000
  316. m_FILTERKEYS.iBounceMSec = 0;
  317. m_MOUSEKEYS.cbSize = 28;
  318. m_MOUSEKEYS.dwFlags = 62; //58
  319. m_MOUSEKEYS.iMaxSpeed = 40;
  320. m_MOUSEKEYS.iTimeToMaxSpeed = 300;
  321. m_MOUSEKEYS.iCtrlSpeed = 80;
  322. m_MOUSEKEYS.dwReserved1 = 0;
  323. m_MOUSEKEYS.dwReserved2 = 0;
  324. m_STICKYKEYS.cbSize = 8;
  325. m_STICKYKEYS.dwFlags = 510; //506
  326. m_TOGGLEKEYS.cbSize = 8;
  327. m_TOGGLEKEYS.dwFlags = 30; //26
  328. m_SOUNDSENTRY.cbSize = 48;
  329. m_SOUNDSENTRY.dwFlags = 2;
  330. m_SOUNDSENTRY.iFSTextEffect = 2;
  331. m_SOUNDSENTRY.iFSTextEffectMSec = 500;
  332. m_SOUNDSENTRY.iFSTextEffectColorBits = 0;
  333. m_SOUNDSENTRY.iFSGrafEffect = 3;
  334. m_SOUNDSENTRY.iFSGrafEffectMSec = 500;
  335. m_SOUNDSENTRY.iFSGrafEffectColor = 0;
  336. m_SOUNDSENTRY.iWindowsEffect = 1;
  337. m_SOUNDSENTRY.iWindowsEffectMSec = 500;
  338. m_SOUNDSENTRY.lpszWindowsEffectDLL = 0;
  339. m_SOUNDSENTRY.iWindowsEffectOrdinal = 0;
  340. m_ACCESSTIMEOUT.cbSize = 12;
  341. m_ACCESSTIMEOUT.dwFlags = 2; //3
  342. m_ACCESSTIMEOUT.iTimeOutMSec = 300000;
  343. m_bShowSounds = 0;
  344. m_bShowExtraKeyboardHelp = 0;
  345. m_bSwapMouseButtons = 0;
  346. m_nMouseTrails = 0;
  347. m_nMouseSpeed = 10;
  348. m_dwCaretWidth = 1;
  349. m_uCursorBlinkTime = 530;
  350. m_nIconSize = 32;
  351. m_nCursorScheme = 1;
  352. _ASSERTE(sizeof(m_FILTERKEYS) == m_FILTERKEYS.cbSize);
  353. _ASSERTE(sizeof(m_MOUSEKEYS) == m_MOUSEKEYS.cbSize);
  354. _ASSERTE(sizeof(m_STICKYKEYS) == m_STICKYKEYS.cbSize);
  355. _ASSERTE(sizeof(m_TOGGLEKEYS) == m_TOGGLEKEYS.cbSize);
  356. _ASSERTE(sizeof(m_SOUNDSENTRY) == m_SOUNDSENTRY.cbSize);
  357. _ASSERTE(sizeof(m_ACCESSTIMEOUT) == m_ACCESSTIMEOUT.cbSize);
  358. m_PortableNonClientMetrics.SetToWindowsDefault();
  359. }
  360. void AddChangesLine(int nId, LPTSTR szBuffer)
  361. {
  362. TCHAR szTemp[80];
  363. LoadString(g_hInstDll, nId, szTemp, ARRAYSIZE(szTemp));
  364. lstrcat(szBuffer, szTemp);
  365. lstrcat(szBuffer, __TEXT("\r\n"));
  366. }
  367. void ReportChanges(const WIZSCHEME &schemeOriginal, HWND hwndChanges)
  368. {
  369. TCHAR szChanges[80*20];
  370. szChanges[0] = 0;
  371. // Check for change in colors
  372. if(0 != memcmp(schemeOriginal.m_rgb, m_rgb, sizeof(m_rgb)))
  373. AddChangesLine(IDS_CHANGESCOLOR, szChanges);
  374. #define TEST_CHANGES(xxx) if(0 != memcmp(&schemeOriginal.m_##xxx, &m_##xxx, sizeof(schemeOriginal.m_##xxx))) AddChangesLine(IDS_CHANGES##xxx, szChanges)
  375. TEST_CHANGES(FILTERKEYS);
  376. TEST_CHANGES(MOUSEKEYS);
  377. TEST_CHANGES(STICKYKEYS);
  378. TEST_CHANGES(TOGGLEKEYS);
  379. TEST_CHANGES(SOUNDSENTRY);
  380. TEST_CHANGES(ACCESSTIMEOUT);
  381. // TEST_CHANGES(SERIALKEYS);
  382. #define TEST_CHANGES2(xxx) if(schemeOriginal.m_b##xxx != m_b##xxx) AddChangesLine(IDS_CHANGES##xxx, szChanges)
  383. TEST_CHANGES2(ShowSounds);
  384. TEST_CHANGES2(ShowExtraKeyboardHelp);
  385. TEST_CHANGES2(SwapMouseButtons);
  386. #define TEST_CHANGES3(xxx) if(schemeOriginal.m_n##xxx != m_n##xxx) AddChangesLine(IDS_CHANGES##xxx, szChanges)
  387. TEST_CHANGES3(MouseTrails);
  388. TEST_CHANGES3(MouseSpeed);
  389. TEST_CHANGES3(IconSize);
  390. TEST_CHANGES3(CursorScheme);
  391. // Add Caret changes
  392. if (schemeOriginal.m_dwCaretWidth != m_dwCaretWidth)
  393. AddChangesLine(IDS_CHANGESCaretWidth, szChanges);
  394. if (schemeOriginal.m_uCursorBlinkTime != m_uCursorBlinkTime)
  395. AddChangesLine(IDS_CHANGESBlinkRate, szChanges);
  396. // TODO: ScrollWidth and BorderWidth have been removed
  397. // TODO: This provieds only one broad change line for all metric changes (including border/scroll bar)
  398. // NOTE: we have to check if any of our portable metrics are different, OR, windows is currently
  399. // not using the default windows font.
  400. PORTABLE_NONCLIENTMETRICS pncm1(schemeOriginal.m_PortableNonClientMetrics);
  401. PORTABLE_NONCLIENTMETRICS pncm2(m_PortableNonClientMetrics);
  402. pncm1.m_nFontFaces = pncm2.m_nFontFaces = 0; // WE MUST IGNORE THIS VALUE WHEN COMPARING
  403. if( 0 != memcmp(&pncm1, &pncm2, sizeof(pncm1))
  404. || (m_PortableNonClientMetrics.m_nFontFaces == 1 && IsCurrentFaceNamesDifferent()))
  405. AddChangesLine(IDS_CHANGESNONCLIENTMETRICS, szChanges);
  406. if(!lstrlen(szChanges))
  407. AddChangesLine(IDS_CHANGESNOCHANGES, szChanges);
  408. SetWindowText(hwndChanges, szChanges);
  409. }
  410. void ApplyChanges(const WIZSCHEME &schemeNew, NONCLIENTMETRICS *pForceNCM = NULL, LOGFONT *pForcelfIcon = NULL);
  411. ////////////////////////////////////////////////////////////
  412. // Setting the icon size
  413. static DWORD SetShellLargeIconSize( DWORD dwNewSize )
  414. {
  415. #define MAX_LENGTH 512
  416. HKEY hKey;
  417. DWORD dwOldSize = dwNewSize;
  418. // open the registry
  419. if (ERROR_SUCCESS == RegOpenKeyEx( HKEY_CURRENT_USER
  420. , TEXT("Control Panel\\desktop\\WindowMetrics"),0
  421. , KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey))
  422. {
  423. DWORD dwLength = MAX_LENGTH, dwType = REG_SZ;
  424. TCHAR szBuffer[MAX_LENGTH];
  425. ZeroMemory(szBuffer, sizeof szBuffer);
  426. // get the last size so we can return it
  427. if (ERROR_SUCCESS == RegQueryValueEx( hKey, TEXT("Shell Icon Size")
  428. , NULL, &dwType, (LPBYTE)szBuffer, &dwLength))
  429. {
  430. szBuffer[MAX_LENGTH-1] = TEXT('\0'); // ensure NUL termination
  431. dwOldSize = _ttol( szBuffer );
  432. // We will allow only values >=16 and <=72
  433. if( (dwNewSize>=16) && (dwNewSize<=72) )
  434. {
  435. // get the current cell size of icon (includes spacing)
  436. ICONMETRICS iconmetrics;
  437. iconmetrics.cbSize = sizeof(ICONMETRICS);
  438. SystemParametersInfo(SPI_GETICONMETRICS, sizeof(ICONMETRICS), &iconmetrics, 0);
  439. // compute the new cell size (including spacing)
  440. iconmetrics.iHorzSpacing = dwNewSize + DEF_SPACING;
  441. iconmetrics.iVertSpacing = iconmetrics.iHorzSpacing;
  442. // update both the icon size and icon cell size and send notifications
  443. wsprintf( szBuffer, TEXT("%d"), dwNewSize );
  444. RegSetValueEx( hKey, TEXT("Shell Icon Size"), 0, REG_SZ, (LPBYTE)szBuffer,
  445. (lstrlen(szBuffer) + 1) * sizeof(TCHAR) );
  446. SystemParametersInfo(SPI_SETICONMETRICS, sizeof(ICONMETRICS)
  447. , &iconmetrics, SPIF_SENDWININICHANGE);
  448. SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETICONMETRICS
  449. , 0/*(LPARAM)("WindowMetrics")*/ );
  450. }
  451. }
  452. // Clean up
  453. RegCloseKey( hKey );
  454. }
  455. // Let everyone know that things changed
  456. return dwOldSize;
  457. #undef MAX_LENGTH
  458. }
  459. ///////////////////////////////////////////////////////////////////////////
  460. // New in Whistler
  461. ///////////////////////////////////////////////////////////////////////////
  462. DWORD m_dwCaretWidth;
  463. UINT m_uCursorBlinkTime;
  464. TCHAR m_szWallpaper[MAX_THEME_SZ];
  465. TCHAR m_szThemeName[MAX_THEME_SZ];
  466. TCHAR m_szThemeColor[MAX_THEME_SZ];
  467. TCHAR m_szThemeSize[MAX_THEME_SZ];
  468. BOOL m_fFlatMenus;
  469. BOOL m_fDropShadows;
  470. TCHAR m_szSelectedStyle[MAX_NUM_SZ]; // this is a number 0 thru 21 (21 color schemes)
  471. int m_nSelectedSize; // this is a number 0 thru 3 (normal, large, extra large)
  472. void UpdateSelectedSize(int nSelectedSize, LPCTSTR pszSelectedStyle);
  473. void SetHCFlag(BOOL fSetOn);
  474. void SaveTheme();
  475. BOOL SetTheme(LPCTSTR pszThemeName, LPCTSTR pszThemeColor, LPCTSTR pszThemeSize);
  476. void ClearTheme()
  477. {
  478. m_szThemeName[0] = 0;
  479. m_szThemeColor[0] = 0;
  480. m_szThemeSize[0] = 0;
  481. }
  482. void SaveWallpaper();
  483. void SetWallpaper(LPCTSTR pszWallpaper);
  484. void ClearWallpaper()
  485. {
  486. m_szWallpaper[0] = 0;
  487. }
  488. void SetStyleNSize();
  489. };
  490. int GetSchemeCount();
  491. void GetSchemeName(int nIndex, LPTSTR lpszName, int nLen);
  492. SCHEMEDATALOCAL &GetScheme(int nIndex);
  493. //////////////////////////////////////////////////////////////////////////////////
  494. // Legacy scheme structures - only used for reading ACW files
  495. //////////////////////////////////////////////////////////////////////////////////
  496. #define COLOR_MAX_WIN9X 25
  497. #define COLOR_MAX_NT400 25
  498. #define COLOR_MAX_NT500 29
  499. #define COLOR_MAX_NT501 31
  500. #define WIZSCHEME_LEGACY_STRUCT(szStruct, szName, nColors) \
  501. struct szStruct \
  502. { \
  503. szStruct() \
  504. { \
  505. ZeroMemory(this, sizeof(*this)); \
  506. m_cbSize = sizeof(*this); \
  507. m_dwVersion = 0x000000FF; \
  508. } \
  509. DWORD m_cbSize; \
  510. DWORD m_dwVersion; \
  511. COLORREF m_rgb[nColors]; \
  512. FILTERKEYS m_FILTERKEYS; \
  513. MOUSEKEYS m_MOUSEKEYS; \
  514. STICKYKEYS m_STICKYKEYS; \
  515. TOGGLEKEYS m_TOGGLEKEYS; \
  516. SOUNDSENTRY m_SOUNDSENTRY; \
  517. ACCESSTIMEOUT m_ACCESSTIMEOUT; \
  518. BOOL m_bShowSounds; \
  519. BOOL m_bShowExtraKeyboardHelp; \
  520. BOOL m_bSwapMouseButtons; \
  521. int m_nMouseTrails; \
  522. int m_nMouseSpeed; \
  523. int m_nIconSize; \
  524. int m_nCursorScheme; \
  525. PORTABLE_NONCLIENTMETRICS m_PortableNonClientMetrics; \
  526. } szName;
  527. #define WIZSCHEME_COPY_LEGACY(dst, src) \
  528. { \
  529. /* ignore m_cbSize */ \
  530. dst.m_dwVersion = src.m_dwVersion; \
  531. memcpy(dst.m_rgb, src.m_rgb, min(sizeof(dst.m_rgb), sizeof(src.m_rgb))); \
  532. dst.m_FILTERKEYS= src.m_FILTERKEYS; \
  533. dst.m_MOUSEKEYS= src.m_MOUSEKEYS; \
  534. dst.m_STICKYKEYS= src.m_STICKYKEYS; \
  535. dst.m_TOGGLEKEYS= src.m_TOGGLEKEYS; \
  536. dst.m_SOUNDSENTRY= src.m_SOUNDSENTRY; \
  537. dst.m_ACCESSTIMEOUT= src.m_ACCESSTIMEOUT; \
  538. dst.m_bShowSounds= src.m_bShowSounds; \
  539. dst.m_bShowExtraKeyboardHelp= src.m_bShowExtraKeyboardHelp; \
  540. dst.m_bSwapMouseButtons= src.m_bSwapMouseButtons; \
  541. dst.m_nMouseTrails= src.m_nMouseTrails; \
  542. dst.m_nMouseSpeed= src.m_nMouseSpeed; \
  543. dst.m_nIconSize= src.m_nIconSize; \
  544. dst.m_nCursorScheme= src.m_nCursorScheme; \
  545. dst.m_PortableNonClientMetrics= src.m_PortableNonClientMetrics; \
  546. }
  547. ///////////////////////////////////////////
  548. // Stuff for Fonts
  549. int GetFontCount();
  550. void GetFontLogFont(int nIndex, LOGFONT *pLogFont);
  551. #endif // _INC_SCHEMES_H