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.

503 lines
19 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. /* LOOKDLG.C
  3. **
  4. **
  5. **
  6. ** History:
  7. **
  8. */
  9. #include "pch.hxx" // PCH
  10. #pragma hdrstop
  11. #include "AccWiz.h"
  12. #include "desk.h"
  13. #include "deskid.h"
  14. #include "look.h"
  15. #include <commdlg.h>
  16. #include <commctrl.h>
  17. #include <regstr.h>
  18. #include "help.h"
  19. #define RGB_PALETTE 0x02000000
  20. void FAR SetMagicColors(HDC, DWORD, WORD);
  21. #define CENTRIES_3D 3
  22. HPALETTE g_hpal3D = NULL; // only exist if palette device
  23. HPALETTE g_hpalVGA = NULL; // only exist if palette device
  24. BOOL g_bPalette = FALSE; // is this a palette device?
  25. int cyBorder;
  26. int cxBorder;
  27. int cxEdge;
  28. int cyEdge;
  29. HWND g_hwndTooltip;
  30. LOOK_FONT g_fonts[NUM_FONTS];
  31. HBRUSH g_brushes[NT40_COLOR_MAX];
  32. BOOL g_bInit = TRUE;
  33. BOOL g_fProprtySheetExiting = FALSE;
  34. #define METRIC_CHANGE 0x0001
  35. #define COLOR_CHANGE 0x0002
  36. #define SCHEME_CHANGE 0x8000
  37. UINT g_fChanged;
  38. LOOK_SIZE g_sizes[NUM_SIZES] = {
  39. /* SIZE_FRAME */ {0, 0, 50},
  40. /* SIZE_SCROLL */ {0, 8, 100},
  41. /* SIZE_CAPTION */ {0, 8, 100},
  42. /* SIZE_SMCAPTION */ {0, 4, 100},
  43. /* SIZE_MENU */ {0, 8, 100},
  44. /* SIZE_DXICON */ {0, 0, 150}, // x spacing
  45. /* SIZE_DYICON */ {0, 0, 150}, // y spacing
  46. /* SIZE_ICON */ {0, 16, 72}, // shell icon size
  47. /* SIZE_SMICON */ {0, 8, 36}, // shell small icon size
  48. };
  49. LOOK_SIZE g_elCurSize;
  50. #define COLORFLAG_SOLID 0x0001
  51. UINT g_colorFlags[NT40_COLOR_MAX] = {
  52. /* COLOR_SCROLLBAR */ 0,
  53. /* COLOR_DESKTOP */ 0,
  54. /* COLOR_ACTIVECAPTION */ COLORFLAG_SOLID,
  55. /* COLOR_INACTIVECAPTION */ COLORFLAG_SOLID,
  56. /* COLOR_MENU */ COLORFLAG_SOLID,
  57. /* COLOR_WINDOW */ COLORFLAG_SOLID,
  58. /* COLOR_WINDOWFRAME */ COLORFLAG_SOLID,
  59. /* COLOR_MENUTEXT */ COLORFLAG_SOLID,
  60. /* COLOR_WINDOWTEXT */ COLORFLAG_SOLID,
  61. /* COLOR_CAPTIONTEXT */ COLORFLAG_SOLID,
  62. /* COLOR_ACTIVEBORDER */ 0,
  63. /* COLOR_INACTIVEBORDER */ 0,
  64. /* COLOR_APPWORKSPACE */ 0,
  65. /* COLOR_HIGHLIGHT */ COLORFLAG_SOLID,
  66. /* COLOR_HIGHLIGHTTEXT */ COLORFLAG_SOLID,
  67. /* COLOR_3DFACE */ COLORFLAG_SOLID,
  68. /* COLOR_3DSHADOW */ COLORFLAG_SOLID,
  69. /* COLOR_GRAYTEXT */ COLORFLAG_SOLID,
  70. /* COLOR_BTNTEXT */ COLORFLAG_SOLID,
  71. /* COLOR_INACTIVECAPTIONTEXT */ COLORFLAG_SOLID,
  72. /* COLOR_3DHILIGHT */ COLORFLAG_SOLID,
  73. /* COLOR_3DDKSHADOW */ COLORFLAG_SOLID,
  74. /* COLOR_3DLIGHT */ COLORFLAG_SOLID,
  75. /* COLOR_INFOTEXT */ COLORFLAG_SOLID,
  76. /* COLOR_INFOBK */ 0,
  77. /* COLOR_3DALTFACE */ COLORFLAG_SOLID,
  78. /* COLOR_HOTLIGHT */ COLORFLAG_SOLID,
  79. /* COLOR_GRADIENTACTIVECAPTION */ COLORFLAG_SOLID,
  80. /* COLOR_GRADIENTINACTIVECAPTION */ COLORFLAG_SOLID
  81. #if(WINVER >= 0x0501)
  82. /* COLOR_MENUHILIGHT */, COLORFLAG_SOLID,
  83. /* COLOR_MENUBAR */ COLORFLAG_SOLID
  84. #endif /* WINVER >= 0x0501 */
  85. };
  86. // strings for color names.
  87. PTSTR s_pszColorNames[NT40_COLOR_MAX] = {
  88. /* COLOR_SCROLLBAR */ TEXT("Scrollbar"),
  89. /* COLOR_DESKTOP */ TEXT("Background"),
  90. /* COLOR_ACTIVECAPTION */ TEXT("ActiveTitle"),
  91. /* COLOR_INACTIVECAPTION */ TEXT("InactiveTitle"),
  92. /* COLOR_MENU */ TEXT("Menu"),
  93. /* COLOR_WINDOW */ TEXT("Window"),
  94. /* COLOR_WINDOWFRAME */ TEXT("WindowFrame"),
  95. /* COLOR_MENUTEXT */ TEXT("MenuText"),
  96. /* COLOR_WINDOWTEXT */ TEXT("WindowText"),
  97. /* COLOR_CAPTIONTEXT */ TEXT("TitleText"),
  98. /* COLOR_ACTIVEBORDER */ TEXT("ActiveBorder"),
  99. /* COLOR_INACTIVEBORDER */ TEXT("InactiveBorder"),
  100. /* COLOR_APPWORKSPACE */ TEXT("AppWorkspace"),
  101. /* COLOR_HIGHLIGHT */ TEXT("Hilight"),
  102. /* COLOR_HIGHLIGHTTEXT */ TEXT("HilightText"),
  103. /* COLOR_3DFACE */ TEXT("ButtonFace"),
  104. /* COLOR_3DSHADOW */ TEXT("ButtonShadow"),
  105. /* COLOR_GRAYTEXT */ TEXT("GrayText"),
  106. /* COLOR_BTNTEXT */ TEXT("ButtonText"),
  107. /* COLOR_INACTIVECAPTIONTEXT */ TEXT("InactiveTitleText"),
  108. /* COLOR_3DHILIGHT */ TEXT("ButtonHilight"),
  109. /* COLOR_3DDKSHADOW */ TEXT("ButtonDkShadow"),
  110. /* COLOR_3DLIGHT */ TEXT("ButtonLight"),
  111. /* COLOR_INFOTEXT */ TEXT("InfoText"),
  112. /* COLOR_INFOBK */ TEXT("InfoWindow"),
  113. /* COLOR_3DALTFACE */ TEXT("ButtonAlternateFace"),
  114. /* COLOR_HOTLIGHT */ TEXT("HotTracking"),
  115. /* COLOR_GRADIENTACTIVECAPTION */ TEXT("GradientActiveTitle"),
  116. /* COLOR_GRADIENTINACTIVECAPTION */ TEXT("GradientInactiveTitle")
  117. #if(WINVER >= 0x0501)
  118. /* COLOR_MENUHILIGHT */ ,TEXT("MenuHighlighted"),
  119. /* COLOR_MENUBAR */ TEXT("MenuBar")
  120. #endif /* WINVER >= 0x0501 */
  121. };
  122. TCHAR g_szColors[] = TEXT("colors"); // colors section name
  123. // Location of the Colors subkey in Registry; Defined in RegStr.h
  124. TCHAR szRegStr_Colors[] = REGSTR_PATH_COLORS;
  125. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  126. //this order has to match the enum order in look.h
  127. //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  128. LOOK_ELEMENT g_elements[] = {
  129. /* ELEMENT_APPSPACE */ {COLOR_APPWORKSPACE, SIZE_NONE, FALSE, COLOR_NONE, FONT_NONE, ELNAME_APPSPACE, -1, {-1,-1,-1,-1}, COLOR_NONE},
  130. /* ELEMENT_DESKTOP */ {COLOR_BACKGROUND, SIZE_NONE, FALSE, COLOR_NONE, FONT_NONE, ELNAME_DESKTOP, -1, {-1,-1,-1,-1}, COLOR_NONE},
  131. /* ELEMENT_INACTIVEBORDER */ {COLOR_INACTIVEBORDER, SIZE_FRAME, FALSE, COLOR_NONE, FONT_NONE, ELNAME_INACTIVEBORDER, -1, {-1,-1,-1,-1}, COLOR_NONE},
  132. /* ELEMENT_ACTIVEBORDER */ {COLOR_ACTIVEBORDER, SIZE_FRAME, FALSE, COLOR_NONE, FONT_NONE, ELNAME_ACTIVEBORDER, -1, {-1,-1,-1,-1}, COLOR_NONE},
  133. /* ELEMENT_INACTIVECAPTION */ {COLOR_INACTIVECAPTION, SIZE_CAPTION, TRUE, COLOR_INACTIVECAPTIONTEXT,FONT_CAPTION,ELNAME_INACTIVECAPTION, -1,{-1,-1,-1,-1}, COLOR_GRADIENTINACTIVECAPTION},
  134. /* ELEMENT_INACTIVESYSBUT1 */ {COLOR_NONE, SIZE_CAPTION, FALSE, COLOR_NONE, FONT_NONE, -1, ELEMENT_ACTIVESYSBUT1, {-1,-1,-1,-1}, COLOR_NONE},
  135. /* ELEMENT_INACTIVESYSBUT2 */ {COLOR_NONE, SIZE_CAPTION, FALSE, COLOR_NONE, FONT_NONE, -1, ELEMENT_ACTIVESYSBUT1, {-1,-1,-1,-1}, COLOR_NONE},
  136. /* ELEMENT_ACTIVECAPTION */ {COLOR_ACTIVECAPTION, SIZE_CAPTION, TRUE, COLOR_CAPTIONTEXT, FONT_CAPTION, ELNAME_ACTIVECAPTION, -1, {-1,-1,-1,-1}, COLOR_GRADIENTACTIVECAPTION},
  137. /* ELEMENT_ACTIVESYSBUT1 */ {COLOR_NONE, SIZE_CAPTION, FALSE, COLOR_NONE, FONT_NONE, ELNAME_CAPTIONBUTTON, -1, {-1,-1,-1,-1}, COLOR_NONE},
  138. /* ELEMENT_ACTIVESYSBUT2 */ {COLOR_NONE, SIZE_CAPTION, FALSE, COLOR_NONE, FONT_NONE, -1, ELEMENT_ACTIVESYSBUT1, {-1,-1,-1,-1}, COLOR_NONE},
  139. /* ELEMENT_MENUNORMAL */ {COLOR_MENU, SIZE_MENU, TRUE, COLOR_MENUTEXT, FONT_MENU, ELNAME_MENU, -1, {-1,-1,-1,-1}, COLOR_NONE},
  140. /* ELEMENT_MENUSELECTED */ {COLOR_HIGHLIGHT, SIZE_MENU, TRUE, COLOR_HIGHLIGHTTEXT, FONT_MENU, ELNAME_MENUSELECTED, -1, {-1,-1,-1,-1}, COLOR_NONE},
  141. /* ELEMENT_MENUDISABLED */ {COLOR_MENU, SIZE_MENU, TRUE, COLOR_NONE, FONT_MENU, -1, ELEMENT_MENUNORMAL, {-1,-1,-1,-1}, COLOR_NONE},
  142. /* ELEMENT_WINDOW */ {COLOR_WINDOW, SIZE_NONE, FALSE, COLOR_WINDOWTEXT, FONT_NONE, ELNAME_WINDOW, -1, {-1,-1,-1,-1}, COLOR_NONE},
  143. /* ELEMENT_MSGBOX */ {COLOR_NONE, SIZE_NONE, TRUE, COLOR_WINDOWTEXT, FONT_MSGBOX, ELNAME_MSGBOX, -1, {-1,-1,-1,-1}, COLOR_NONE},
  144. /* ELEMENT_MSGBOXCAPTION */ {COLOR_ACTIVECAPTION, SIZE_CAPTION, TRUE, COLOR_CAPTIONTEXT, FONT_CAPTION, -1, ELEMENT_ACTIVECAPTION, {-1,-1,-1,-1}, COLOR_NONE},
  145. /* ELEMENT_MSGBOXSYSBUT */ {COLOR_3DFACE, SIZE_CAPTION, TRUE, COLOR_BTNTEXT, FONT_CAPTION, -1, ELEMENT_ACTIVESYSBUT1, {-1,-1,-1,-1}, COLOR_NONE},
  146. // do not even try to set a scrollbar color the system will ignore you
  147. /* ELEMENT_SCROLLBAR */ {COLOR_NONE, SIZE_SCROLL, FALSE, COLOR_NONE, FONT_NONE, ELNAME_SCROLLBAR, -1, {-1,-1,-1,-1}, COLOR_NONE},
  148. /* ELEMENT_SCROLLUP */ {COLOR_NONE, SIZE_SCROLL, FALSE, COLOR_NONE, FONT_NONE, -1, ELEMENT_SCROLLBAR, {-1,-1,-1,-1}, COLOR_NONE},
  149. /* ELEMENT_SCROLLDOWN */ {COLOR_NONE, SIZE_SCROLL, FALSE, COLOR_NONE, FONT_NONE, -1, ELEMENT_SCROLLBAR, {-1,-1,-1,-1}, COLOR_NONE},
  150. /* ELEMENT_BUTTON */ {COLOR_3DFACE, SIZE_NONE, FALSE, COLOR_BTNTEXT, FONT_NONE, ELNAME_BUTTON, -1, {-1,-1,-1,-1}, COLOR_NONE},
  151. /* ELEMENT_SMCAPTION */ {COLOR_NONE, SIZE_SMCAPTION, TRUE, COLOR_NONE, FONT_SMCAPTION,ELNAME_SMALLCAPTION, -1, {-1,-1,-1,-1}, COLOR_NONE},
  152. /* ELEMENT_ICON */ {COLOR_NONE, SIZE_ICON, FALSE, COLOR_NONE, FONT_ICONTITLE,ELNAME_ICON, -1, {-1,-1,-1,-1}, COLOR_NONE},
  153. /* ELEMENT_ICONHORZSPACING */ {COLOR_NONE, SIZE_DXICON, FALSE, COLOR_NONE, FONT_NONE, ELNAME_DXICON, -1, {-1,-1,-1,-1}, COLOR_NONE},
  154. /* ELEMENT_ICONVERTSPACING */ {COLOR_NONE, SIZE_DYICON, FALSE, COLOR_NONE, FONT_NONE, ELNAME_DYICON, -1, {-1,-1,-1,-1}, COLOR_NONE},
  155. /* ELEMENT_INFO */ {COLOR_INFOBK, SIZE_NONE, TRUE, COLOR_INFOTEXT, FONT_STATUS, ELNAME_INFO, -1, {-1,-1,-1,-1}, COLOR_NONE},
  156. };
  157. // used by ChooseColor dialog
  158. COLORREF g_CustomColors[16];
  159. // structure used to store a scheme in the registry
  160. #ifdef UNICODE
  161. # define SCHEME_VERSION 2 // Ver 2 == Unicode
  162. #else
  163. # define SCHEME_VERSION 1 // Ver 1 == Win95 ANSI
  164. #endif
  165. /*
  166. * Note -- this must match the High Contrast accessibility code
  167. * in windows\gina\winlogon.
  168. */
  169. typedef struct {
  170. SHORT version;
  171. WORD wDummy; // for alignment
  172. NONCLIENTMETRICS ncm;
  173. LOGFONT lfIconTitle;
  174. COLORREF rgb[NT40_COLOR_MAX];
  175. } SCHEMEDATA;
  176. HWND g_hDlg = NULL; // nonzero if page is up
  177. int g_iCurElement = -2; // start off as not even "not set"
  178. int g_LogDPI = 96; // logical resolution of display
  179. #define ELCUR (g_elements[g_iCurElement])
  180. #define ELCURFONT (g_fonts[ELCUR.iFont])
  181. // this one kept separately for range purposes
  182. #define ELCURSIZE g_elCurSize
  183. int g_iPrevSize = SIZE_NONE;
  184. #define MAXSCHEMENAME 100
  185. TCHAR g_szCurScheme[MAXSCHEMENAME]; // current scheme name
  186. TCHAR g_szLastScheme[MAXSCHEMENAME]; // last scheme they had
  187. HBRUSH g_hbrMainColor = NULL;
  188. HBRUSH g_hbrTextColor = NULL;
  189. HBRUSH g_hbrGradColor = NULL;
  190. const TCHAR c_szRegPathUserMetrics[] = TEXT("Control Panel\\Desktop\\WindowMetrics");
  191. const TCHAR c_szRegValIconSize[] = TEXT("Shell Icon Size");
  192. const TCHAR c_szRegValSmallIconSize[] = TEXT("Shell Small Icon Size");
  193. void NEAR PASCAL Look_Repaint(HWND hDlg, BOOL bRecalc);
  194. BOOL NEAR PASCAL Look_ChangeColor(HWND hDlg, int iColor, COLORREF rgb);
  195. BOOL CALLBACK SaveSchemeDlgProc(HWND, UINT, WPARAM, LPARAM);
  196. void NEAR PASCAL Look_UpdateSizeBasedOnFont(HWND hDlg, BOOL fComputeIdeal);
  197. void NEAR PASCAL Look_SetCurSizeAndRange(HWND hDlg);
  198. void NEAR PASCAL Look_SyncSize(HWND hDlg);
  199. void NEAR PASCAL Look_DoSizeStuff(HWND hDlg, BOOL fCanComputeIdeal);
  200. COLORREF GetNearestPaletteColor(HPALETTE hpal, COLORREF rgb)
  201. {
  202. PALETTEENTRY pe;
  203. GetPaletteEntries(hpal, GetNearestPaletteIndex(hpal, rgb & 0x00FFFFFF), 1, &pe);
  204. return RGB(pe.peRed, pe.peGreen, pe.peBlue);
  205. }
  206. BOOL IsPaletteColor(HPALETTE hpal, COLORREF rgb)
  207. {
  208. return GetNearestPaletteColor(hpal, rgb) == (rgb & 0xFFFFFF);
  209. }
  210. COLORREF NearestColor(int iColor, COLORREF rgb)
  211. {
  212. rgb &= 0x00FFFFFF;
  213. //
  214. // if we are on a palette device, we need to do special stuff...
  215. //
  216. if (g_bPalette)
  217. {
  218. if (g_colorFlags[iColor] & COLORFLAG_SOLID)
  219. {
  220. if (IsPaletteColor(g_hpal3D, rgb))
  221. rgb |= RGB_PALETTE;
  222. else
  223. rgb = GetNearestPaletteColor(g_hpalVGA, rgb);
  224. }
  225. else
  226. {
  227. if (IsPaletteColor(g_hpal3D, rgb))
  228. rgb |= RGB_PALETTE;
  229. else if (IsPaletteColor((HPALETTE)GetStockObject(DEFAULT_PALETTE), rgb))
  230. rgb ^= 0x000001; // force a dither
  231. }
  232. }
  233. else
  234. {
  235. // map color to nearest color if we need to for this UI element.
  236. if (g_colorFlags[iColor] & COLORFLAG_SOLID)
  237. {
  238. HDC hdc = GetDC(NULL);
  239. rgb = GetNearestColor(hdc, rgb);
  240. ReleaseDC(NULL, hdc);
  241. }
  242. }
  243. return rgb;
  244. }
  245. void NEAR PASCAL Set3DPaletteColor(COLORREF rgb, int iColor)
  246. {
  247. int iPalette;
  248. PALETTEENTRY pe;
  249. if (!g_hpal3D)
  250. return;
  251. switch (iColor)
  252. {
  253. case COLOR_3DFACE:
  254. iPalette = 16;
  255. break;
  256. case COLOR_3DSHADOW:
  257. iPalette = 17;
  258. break;
  259. case COLOR_3DHILIGHT:
  260. iPalette = 18;
  261. break;
  262. default:
  263. return;
  264. }
  265. pe.peRed = GetRValue(rgb);
  266. pe.peGreen = GetGValue(rgb);
  267. pe.peBlue = GetBValue(rgb);
  268. pe.peFlags = 0;
  269. SetPaletteEntries(g_hpal3D, iPalette, 1, (LPPALETTEENTRY)&pe);
  270. }
  271. void NEAR PASCAL Look_RebuildSysStuff(BOOL fInit)
  272. {
  273. int i;
  274. PALETTEENTRY pal[4];
  275. HPALETTE hpal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
  276. SelectObject(g_hdcMem, GetStockObject(BLACK_BRUSH));
  277. SelectObject(g_hdcMem, GetStockObject(SYSTEM_FONT));
  278. for (i = 0; i < NUM_FONTS; i++)
  279. {
  280. if (g_fonts[i].hfont)
  281. DeleteObject(g_fonts[i].hfont);
  282. g_fonts[i].hfont = CreateFontIndirect(&g_fonts[i].lf);
  283. }
  284. if (fInit)
  285. {
  286. // get current magic colors
  287. GetPaletteEntries(hpal, 8, 4, pal);
  288. SetPaletteEntries(g_hpal3D, 16, 4, pal);
  289. // set up magic colors in the 3d palette
  290. if (!IsPaletteColor(hpal, g_Options.m_schemePreview.m_rgb[COLOR_3DFACE]))
  291. {
  292. Set3DPaletteColor(g_Options.m_schemePreview.m_rgb[COLOR_3DFACE], COLOR_3DFACE);
  293. Set3DPaletteColor(g_Options.m_schemePreview.m_rgb[COLOR_3DSHADOW], COLOR_3DSHADOW);
  294. Set3DPaletteColor(g_Options.m_schemePreview.m_rgb[COLOR_3DHILIGHT], COLOR_3DHILIGHT);
  295. }
  296. }
  297. for (i = 0; i < NT40_COLOR_MAX; i++)
  298. {
  299. if (g_brushes[i])
  300. DeleteObject(g_brushes[i]);
  301. g_brushes[i] = CreateSolidBrush(NearestColor(i, g_Options.m_schemePreview.m_rgb[i]));
  302. }
  303. }
  304. #ifndef LF32toLF
  305. void NEAR LF32toLF(LPLOGFONT_32 lplf32, LPLOGFONT lplf)
  306. {
  307. lplf->lfHeight = (int) lplf32->lfHeight;
  308. lplf->lfWidth = (int) lplf32->lfWidth;
  309. lplf->lfEscapement = (int) lplf32->lfEscapement;
  310. lplf->lfOrientation = (int) lplf32->lfOrientation;
  311. lplf->lfWeight = (int) lplf32->lfWeight;
  312. *((LPCOMMONFONT) &lplf->lfItalic) = lplf32->lfCommon;
  313. }
  314. #endif
  315. void NEAR SetMyNonClientMetrics(LPNONCLIENTMETRICS lpncm)
  316. {
  317. g_sizes[SIZE_FRAME].CurSize = (int)lpncm->iBorderWidth;
  318. g_sizes[SIZE_SCROLL].CurSize = (int)lpncm->iScrollWidth;
  319. g_sizes[SIZE_CAPTION].CurSize = (int)lpncm->iCaptionHeight;
  320. g_sizes[SIZE_SMCAPTION].CurSize = (int)lpncm->iSmCaptionHeight;
  321. g_sizes[SIZE_MENU].CurSize = (int)lpncm->iMenuHeight;
  322. LF32toLF(&(lpncm->lfCaptionFont), &(g_fonts[FONT_CAPTION].lf));
  323. LF32toLF(&(lpncm->lfSmCaptionFont), &(g_fonts[FONT_SMCAPTION].lf));
  324. LF32toLF(&(lpncm->lfMenuFont), &(g_fonts[FONT_MENU].lf));
  325. LF32toLF(&(lpncm->lfStatusFont), &(g_fonts[FONT_STATUS].lf));
  326. LF32toLF(&(lpncm->lfMessageFont), &(g_fonts[FONT_MSGBOX].lf));
  327. }
  328. /*
  329. ** Fill in a NONCLIENTMETRICS structure with latest preview stuff
  330. */
  331. void NEAR GetMyNonClientMetrics(LPNONCLIENTMETRICS lpncm)
  332. {
  333. lpncm->iBorderWidth = (LONG)g_sizes[SIZE_FRAME].CurSize;
  334. lpncm->iScrollWidth = lpncm->iScrollHeight = (LONG)g_sizes[SIZE_SCROLL].CurSize;
  335. lpncm->iCaptionWidth = lpncm->iCaptionHeight = (LONG)g_sizes[SIZE_CAPTION].CurSize;
  336. lpncm->iSmCaptionWidth = lpncm->iSmCaptionHeight = (LONG)g_sizes[SIZE_SMCAPTION].CurSize;
  337. lpncm->iMenuWidth = lpncm->iMenuHeight = (LONG)g_sizes[SIZE_MENU].CurSize;
  338. LFtoLF32(&(g_fonts[FONT_CAPTION].lf), &(lpncm->lfCaptionFont));
  339. LFtoLF32(&(g_fonts[FONT_SMCAPTION].lf), &(lpncm->lfSmCaptionFont));
  340. LFtoLF32(&(g_fonts[FONT_MENU].lf), &(lpncm->lfMenuFont));
  341. LFtoLF32(&(g_fonts[FONT_STATUS].lf), &(lpncm->lfStatusFont));
  342. LFtoLF32(&(g_fonts[FONT_MSGBOX].lf), &(lpncm->lfMessageFont));
  343. }
  344. /*
  345. ** clean up any mess made in maintaining system information
  346. ** also, write out any global changes in our setup.
  347. */
  348. void NEAR PASCAL Look_DestroySysStuff(void)
  349. {
  350. int i;
  351. HKEY hkAppear;
  352. SelectObject(g_hdcMem, GetStockObject(BLACK_BRUSH));
  353. SelectObject(g_hdcMem, GetStockObject(SYSTEM_FONT));
  354. for (i = 0; i < NUM_FONTS; i++)
  355. {
  356. if (g_fonts[i].hfont)
  357. DeleteObject(g_fonts[i].hfont);
  358. }
  359. for (i = 0; i < NT40_COLOR_MAX; i++)
  360. {
  361. if (g_brushes[i])
  362. DeleteObject(g_brushes[i]);
  363. }
  364. if (g_hpal3D)
  365. DeleteObject(g_hpal3D);
  366. if (g_hpalVGA)
  367. DeleteObject(g_hpalVGA);
  368. // save out possible changes to custom color table
  369. if (RegOpenKey(HKEY_CURRENT_USER, REGSTR_PATH_APPEARANCE, &hkAppear) == ERROR_SUCCESS)
  370. {
  371. RegSetValueEx(hkAppear, REGSTR_VAL_CUSTOMCOLORS, 0L, REG_BINARY,
  372. (LPBYTE)g_CustomColors, sizeof(g_CustomColors));
  373. }
  374. }
  375. //------------------------ mini font picker controls --------------------------
  376. /*
  377. ** initialize the constant dialog components
  378. **
  379. ** initialize the list of element names. this stays constant with the
  380. ** possible exception that some items might be added/removed depending
  381. ** on some special case conditions.
  382. */
  383. void NEAR PASCAL Look_DestroyDialog(HWND hDlg)
  384. {
  385. HFONT hfont, hfontOther;
  386. hfontOther = (HFONT)SendDlgItemMessage(hDlg, IDC_MAINSIZE, WM_GETFONT, 0, 0L);
  387. hfont = (HFONT)SendDlgItemMessage(hDlg, IDC_FONTBOLD, WM_GETFONT, 0, 0L);
  388. if (hfont && (hfont != hfontOther))
  389. DeleteObject(hfont);
  390. hfont = (HFONT)SendDlgItemMessage(hDlg, IDC_FONTITAL, WM_GETFONT, 0, 0L);
  391. if (hfont && (hfont != hfontOther))
  392. DeleteObject(hfont);
  393. DestroyWindow(g_hwndTooltip);
  394. }
  395. #define LSE_SETCUR 0x0001
  396. #define LSE_ALWAYS 0x0002
  397. const static DWORD FAR aAppearanceHelpIds[] = {
  398. IDC_SCHEMES, IDH_APPEAR_SCHEME,
  399. IDC_SAVESCHEME, IDH_APPEAR_SAVEAS,
  400. IDC_DELSCHEME, IDH_APPEAR_DELETE,
  401. IDC_ELEMENTS, IDH_APPEAR_ITEM,
  402. IDC_MAINCOLOR, IDH_APPEAR_BACKGRNDCOLOR,
  403. IDC_SIZELABEL, IDH_APPEAR_ITEMSIZE,
  404. IDC_MAINSIZE, IDH_APPEAR_ITEMSIZE,
  405. IDC_SIZEARROWS, IDH_APPEAR_ITEMSIZE,
  406. IDC_FONTLABEL, IDH_APPEAR_FONT,
  407. IDC_FONTNAME, IDH_APPEAR_FONT,
  408. IDC_FONTSIZE, IDH_APPEAR_FONTSIZE,
  409. IDC_FONTBOLD, IDH_APPEAR_FONTBOLD,
  410. IDC_FONTITAL, IDH_APPEAR_FONTITALIC,
  411. IDC_LOOKPREV, IDH_APPEAR_GRAPHIC,
  412. IDC_FONTSIZELABEL, IDH_APPEAR_FONTSIZE,
  413. IDC_COLORLABEL, IDH_APPEAR_BACKGRNDCOLOR,
  414. IDC_TEXTCOLOR, IDH_APPEAR_FONTCOLOR,
  415. IDC_FNCOLORLABEL, IDH_APPEAR_FONTCOLOR,
  416. 0, 0
  417. };
  418. LONG WINAPI MyStrToLong(LPCTSTR sz)
  419. {
  420. long l=0;
  421. while (*sz >= TEXT('0') && *sz <= TEXT('9'))
  422. l = l*10 + (*sz++ - TEXT('0'));
  423. return l;
  424. }