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.

673 lines
23 KiB

  1. /* NC.C
  2. Resident Code Segment // Tweak: make non-resident?
  3. Routines for reading and writing Non-client metrics, and icons.
  4. Roughly: Borders and Fonts and Icons stuff.
  5. GatherIconMetricsByHand();
  6. GatherNonClientMetricsByHand();
  7. SetIconMetricsByHand();
  8. SetNonClientMetricsByHand();
  9. Unlike all of the other items, we do not read and write these to the
  10. registry directly. Instead, we use the SystemParametersInfo(GET/SET)
  11. API.
  12. ***
  13. This is a low-header-comment file. The four functions just read and write
  14. two sets of params. Comments within the functions show the simple goings-
  15. on.
  16. Uses: global pValue buffer from REGUTILS.C
  17. ***
  18. Frosting: Master Theme Selector for Windows '95
  19. Copyright (c) 1994-1999 Microsoft Corporation. All rights reserved.
  20. */
  21. // ---------------------------------------------
  22. // Brief file history:
  23. // Alpha:
  24. // Beta:
  25. // Bug fixes
  26. // ---------
  27. //
  28. // ---------------------------------------------
  29. #include "windows.h"
  30. #include <mbctype.h>
  31. #include "frost.h"
  32. #include "nc.h"
  33. ////////////////////////////////////////////////
  34. //
  35. // E X T E R N A L F U N C T I O N S
  36. //
  37. // Uses external functions in REGUTILS.C,
  38. // which was going to be the only function to
  39. // read and write -- until we found we couldn't
  40. // do these parameters live directly to the registry.
  41. //
  42. ////////////////////////////////////////////////
  43. extern BOOL FAR WriteBytesToFile(LPTSTR, LPTSTR, BYTE *, int, LPTSTR);
  44. extern int FAR WriteBytesToBuffer(LPTSTR);
  45. //
  46. // LOCAL ROUTINES
  47. //
  48. //
  49. // LOCAL GLOBALS
  50. extern BOOL bReadOK, bWroteOK;
  51. ////////////////////////////////////////////////
  52. //
  53. // FONTS and BORDERS and ICONS
  54. //
  55. // These are done by hand only!
  56. // These are all read and set with SystemParametersInfo() instead of reading
  57. // and writing directly to the registry like the naughty app we are with most
  58. // of the above.
  59. //
  60. // General
  61. TCHAR szMetrics[] = TEXT("Metrics");
  62. TCHAR szNCM[] = TEXT("NonclientMetrics");
  63. TCHAR szIM[] = TEXT("IconMetrics");
  64. TCHAR szCP_DT_WM[] = TEXT("Control Panel\\Desktop\\WindowMetrics");
  65. TCHAR szIconSize[] = TEXT("Shell Icon Size");
  66. TCHAR szSmallIconSize[] = TEXT("Shell Small Icon Size");
  67. #ifdef FOO
  68. // BORDERS
  69. TCHAR szBorderWidth[] = TEXT("BorderWidth");
  70. TCHAR szScrollWidth[] = TEXT("ScrollWidth");
  71. TCHAR szScrollHeight[] = TEXT("ScrollHeight");
  72. TCHAR szCapWidth[] = TEXT("CaptionWidth");
  73. TCHAR szCapHeight[] = TEXT("CaptionHeight");
  74. TCHAR szSmCapWidth[] = TEXT("SmCaptionWidth");
  75. TCHAR szSmCapHeight[] = TEXT("SmCaptionHeight");
  76. TCHAR szMenuWidth[] = TEXT("MenuWidth");
  77. TCHAR szMenuHeight[] = TEXT("MenuHeight");
  78. // FONTS styles and names and sizes mixed together
  79. TCHAR szCapFont[] = TEXT("CaptionFont");
  80. TCHAR szSmCapFont[] = TEXT("SmCaptionFont");
  81. TCHAR szMenuFont[] = TEXT("MenuFont");
  82. TCHAR szStatFont[] = TEXT("StatusFont");
  83. TCHAR szMsgFont[] = TEXT("MessageFont");
  84. // ICONS
  85. TCHAR szIconFont[] = TEXT("IconFont");
  86. TCHAR szIconVertSpacing[] = TEXT("IconVertSpacing");
  87. TCHAR szIconHorzSpacing[] = TEXT("IconHorzSpacing");
  88. #endif
  89. // These two are in the registry, but do not correspond to
  90. // anything in the Display CPL or SystemParametersInfo() code.
  91. // I assume that these are set internally by the system
  92. // based on the icon size (set directly in the registry earlier)
  93. // and horz/vert spacing (set right above). DB will test
  94. // and if it works for his themes, then we're there.
  95. // "IconSpacing";
  96. // "IconSpacingFactor";
  97. // Later added these two by hand, in and out of reg, so can
  98. // check for null values.
  99. //
  100. // {TEXT("Shell Icon Size"), REG_SZ, FC_ICONS},
  101. // {TEXT("Shell Small Icon Size"), REG_SZ, FC_ICONS},
  102. BOOL FAR GatherIconMetricsByHand(LPTSTR lpszTheme)
  103. {
  104. ICONMETRICS im;
  105. // BOOL bOK, bret;
  106. BOOL bOK;
  107. extern BOOL bReadOK, bWroteOK;
  108. #ifdef UNICODE
  109. #ifdef FUDDY_DUDDY
  110. CHAR szTempA[10];
  111. #endif
  112. ICONMETRICSA imA;
  113. #endif
  114. // inits
  115. im.cbSize = sizeof(im);
  116. bOK = SystemParametersInfo(SPI_GETICONMETRICS, sizeof(im),
  117. (void far *)(LPICONMETRICS)&im, FALSE);
  118. if (!bOK) bReadOK = FALSE;
  119. // write the whole kit and kaboodle
  120. #ifdef UNICODE
  121. // Need to convert the ICONMETRICS structure to ANSI before writing
  122. // to the Theme file.
  123. ConvertIconMetricsToANSI((LPICONMETRICSW)&im, (LPICONMETRICSA)&imA);
  124. if (bOK) {
  125. bOK = WriteBytesToFile((LPTSTR)szMetrics, (LPTSTR)szIM,
  126. (BYTE *)&(imA), sizeof(ICONMETRICSA), lpszTheme);
  127. }
  128. #else
  129. // Currently ANSI so no need to convert ICONMETRICS before writing
  130. // to Theme file
  131. if (bOK) {
  132. bOK = WriteBytesToFile((LPTSTR)szMetrics, (LPTSTR)szIM,
  133. (BYTE *)&(im), sizeof(ICONMETRICS), lpszTheme);
  134. }
  135. #endif // UNICODE
  136. if (!bOK) bWroteOK = FALSE;
  137. #ifdef DOING_ICON_SIZES
  138. //
  139. // now get and store icon sizes
  140. // first Icon Size
  141. bret = HandGet(HKEY_CURRENT_USER, szCP_DT_WM,
  142. szIconSize, (LPTSTR)pValue);
  143. Assert(bret, TEXT("couldn't get IconSize from Registry!\n"));
  144. bOK = bOK && bret;
  145. bret = WritePrivateProfileString((LPTSTR)szCP_DT_WM, (LPTSTR)szIconSize,
  146. // only store if got something, else null
  147. (LPTSTR)(bret ? pValue : szNULL),
  148. lpszTheme);
  149. bOK = bOK && bret;
  150. if (!bret) bWroteOK = FALSE;
  151. // then Small Icon Size
  152. bret = HandGet(HKEY_CURRENT_USER, szCP_DT_WM,
  153. szSmallIconSize, (LPTSTR)pValue);
  154. Assert(bret, TEXT("couldn't get SmallIconSize from Registry!\n"));
  155. bOK = bOK && bret;
  156. bret = WritePrivateProfileString((LPTSTR)szCP_DT_WM, (LPTSTR)szSmallIconSize,
  157. // only store if got something, else null
  158. (LPTSTR)(bret ? pValue : szNULL),
  159. lpszTheme);
  160. bOK = bOK && bret;
  161. if (!bret) bWroteOK = FALSE;
  162. #endif // DOING_ICON_SIZES
  163. #ifdef FUDDY_DUDDY
  164. // 3 writes: translate to string and write to THM file
  165. if (bOK) {
  166. // write font to theme file
  167. // REARCHITECT: if we were really doing this you would want to convert
  168. // this LOGFONT to ANSI before writing to the Theme file.
  169. bRet = WriteBytesToFile((LPTSTR)szMetrics, (LPTSTR)szIconFont,
  170. (BYTE *)&(im.lfFont), sizeof(LOGFONT), lpszTheme);
  171. bOK = bOK && bRet;
  172. // write vert spacing to theme file
  173. #ifdef UNICODE
  174. litoa(im.iVertSpacing, szTempA);
  175. mbstowcs(pValue, szTempA, sizeof(szTempA));
  176. #else
  177. litoa(im.iVertSpacing, (LPTSTR)pValue);
  178. #endif
  179. bRet = WritePrivateProfileString((LPTSTR)szMetrics, (LPTSTR)szIconVertSpacing,
  180. (LPTSTR)pValue, lpszTheme);
  181. bOK = bOK && bRet;
  182. // write horz spacing to theme file
  183. #ifdef UNICODE
  184. litoa(im.iHorzSpacing, szTempA);
  185. mbstowcs(pValue, szTempA, sizeof(szTempA));
  186. #else
  187. litoa(im.iHorzSpacing, (LPTSTR)pValue);
  188. #endif
  189. bRet = WritePrivateProfileString((LPTSTR)szMetrics, (LPTSTR)szIconHorzSpacing,
  190. (LPTSTR)pValue, lpszTheme);
  191. bOK = bOK && bRet;
  192. }
  193. #endif // FUDDY_DUDDY
  194. // cleanup
  195. Assert(bOK, TEXT("problem gathering icon metrics by hand\n"));
  196. return (bOK);
  197. }
  198. BOOL FAR GatherNonClientMetricsByHand(LPTSTR lpszTheme)
  199. {
  200. NONCLIENTMETRICS ncm;
  201. BOOL bOK;
  202. #ifdef UNICODE
  203. NONCLIENTMETRICSA ncmA;
  204. #endif
  205. // inits
  206. ncm.cbSize = sizeof(ncm);
  207. bOK = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm),
  208. (void far *)(LPNONCLIENTMETRICS)&ncm, FALSE);
  209. if (!bOK) bReadOK = FALSE;
  210. // write the whole kit and kaboodle
  211. #ifdef UNICODE
  212. // Need to convert the NONCLIENTMETRICS structure to ANSI before
  213. // writing it to the Theme file
  214. ConvertNCMetricsToANSI((LPNONCLIENTMETRICSW)&ncm, (LPNONCLIENTMETRICSA)&ncmA);
  215. if (bOK) {
  216. bOK = WriteBytesToFile((LPTSTR)szMetrics, (LPTSTR)szNCM,
  217. (BYTE *)&(ncmA), sizeof(NONCLIENTMETRICSA), lpszTheme);
  218. }
  219. #else
  220. // No UNICODE so no need to convert NONCLIENTMETRICS to ANSI
  221. // before writing to Theme file.
  222. if (bOK) {
  223. bOK = WriteBytesToFile((LPTSTR)szMetrics, (LPTSTR)szNCM,
  224. (BYTE *)&(ncm), sizeof(NONCLIENTMETRICS), lpszTheme);
  225. }
  226. #endif // UNICODE
  227. if (!bOK) bWroteOK = FALSE;
  228. // cleanup
  229. Assert(bOK, TEXT("problem gathering nonclient metrics by hand\n"));
  230. return (bOK);
  231. }
  232. //
  233. // SetIconMetricsByHand
  234. //
  235. // When they decided that icon fonts went with fonts not with
  236. // icons, this got a little tangled. Follow the bools.
  237. //
  238. VOID FAR SetIconMetricsByHand(BOOL bIconSpacing, BOOL bIconFont)
  239. {
  240. UINT uret;
  241. ICONMETRICS imCur, imStored;
  242. LONG lret;
  243. HKEY hKey;
  244. //
  245. // INITS
  246. //
  247. // Get cur iconmetrics
  248. imCur.cbSize = sizeof(imCur);
  249. uret = (UINT) SystemParametersInfo(SPI_GETICONMETRICS, sizeof(imCur),
  250. (void far *)(LPICONMETRICS)&imCur, FALSE);
  251. Assert(uret, TEXT("problem getting cur icon metrics before setting\n"));
  252. //
  253. // Get stored iconmetrics
  254. // get stored data string
  255. uret = (UINT) GetPrivateProfileString((LPTSTR)szMetrics, (LPTSTR)szIM,
  256. (LPTSTR)szNULL,
  257. (LPTSTR)pValue, MAX_VALUELEN,
  258. (LPTSTR)szCurThemeFile);
  259. Assert(uret, TEXT("problem getting stored icon metrics before setting\n"));
  260. // if we somehow come up with no icon metrics in the theme, just
  261. // PUNT and leave cur settings
  262. if (*pValue) { // if something there to set
  263. // translate stored data string to ICONMETRICS bytes
  264. WriteBytesToBuffer((LPTSTR)pValue); // char str read from and binary bytes
  265. // written to pValue. It's OK.
  266. // get it into ICONMETRICS structure for ease of use and safety
  267. #ifdef UNICODE
  268. // ICONMETRICS are stored in ANSI format in the Theme file so if
  269. // we're living in a UNICODE world we need to convert from ANSI
  270. // to UNICODE
  271. ConvertIconMetricsToWIDE((LPICONMETRICSA)pValue, (LPICONMETRICSW)&imStored);
  272. #else
  273. // No UNICODE, no need to convert from ANSI...
  274. imStored = *((LPICONMETRICS)pValue);
  275. #endif
  276. //
  277. // Combine the cur and the saved here and now in the imStored struct
  278. imCur.cbSize = sizeof(ICONMETRICS); // paranoid
  279. if (bIconSpacing) {
  280. imCur.iHorzSpacing = imStored.iHorzSpacing;
  281. imCur.iVertSpacing = imStored.iVertSpacing;
  282. }
  283. // iTitleWrap already as was in system
  284. if (bIconFont)
  285. imCur.lfFont = imStored.lfFont;
  286. //
  287. // Set it in the system live
  288. uret = (UINT) SystemParametersInfo(SPI_SETICONMETRICS, sizeof(imCur),
  289. (void far *)(LPICONMETRICS)&imCur,
  290. // send change at end of theme application
  291. SPIF_UPDATEINIFILE);
  292. Assert(uret, TEXT("problem setting icon metrics in cur system!!\n"));
  293. }
  294. // the rest is just for icon size and spacing
  295. if (bIconSpacing) {
  296. //
  297. // now do icon sizes directly to the registry
  298. // open
  299. lret = RegOpenKeyEx(HKEY_CURRENT_USER, szCP_DT_WM,
  300. (DWORD)0, KEY_SET_VALUE, (PHKEY)&hKey );
  301. if (lret == ERROR_SUCCESS) {
  302. GetPrivateProfileString((LPTSTR)szCP_DT_WM, (LPTSTR)szIconSize,
  303. (LPTSTR)szNULL,
  304. (LPTSTR)pValue, MAX_VALUELEN, (LPTSTR)szCurThemeFile);
  305. if (*pValue) { // non-null size settings only!
  306. RegSetValueEx(hKey, (LPTSTR)szIconSize,
  307. 0,
  308. (DWORD)REG_SZ,
  309. (LPBYTE)pValue,
  310. (DWORD)(SZSIZEINBYTES((LPTSTR)pValue) + 1));
  311. }
  312. GetPrivateProfileString((LPTSTR)szCP_DT_WM, (LPTSTR)szSmallIconSize,
  313. (LPTSTR)szNULL,
  314. (LPTSTR)pValue, MAX_VALUELEN, (LPTSTR)szCurThemeFile);
  315. if (*pValue) { // non-null size settings only!
  316. RegSetValueEx(hKey, (LPTSTR)szSmallIconSize,
  317. 0,
  318. (DWORD)REG_SZ,
  319. (LPBYTE)pValue,
  320. (DWORD)(SZSIZEINBYTES((LPTSTR)pValue) + 1 ));
  321. }
  322. // cleanup!
  323. RegCloseKey(hKey);
  324. } // end if opened key
  325. } // end if bIconSpacing
  326. }
  327. //
  328. // SetNonClientMetricsByHand
  329. //
  330. // Borders and fonts are both in the same NONCLIENTMETRICS setting,
  331. // so we have to set them together. Here's what we do:
  332. // Start with cur system settings as default. If we are changing
  333. // font styles, alter the fonts from the default. If we are changing
  334. // window border and font sizes, make those changes to our default copy of
  335. // the metrics and fonts, too.
  336. //
  337. // Then go reset the system.
  338. //
  339. VOID FAR SetNonClientMetricsByHand(BOOL bFonts, BOOL bBorders)
  340. {
  341. UINT uret;
  342. NONCLIENTMETRICS ncmCur, ncmStored;
  343. //
  344. // INITS
  345. //
  346. // Get cur nonclientmetrics: this is the default until we hear otherwise
  347. ncmCur.cbSize = sizeof(ncmCur);
  348. uret = (UINT) SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncmCur),
  349. (void far *)(LPNONCLIENTMETRICS)&ncmCur, FALSE);
  350. Assert(uret, TEXT("problem getting cur nonclient metrics before setting\n"));
  351. //
  352. // Get stored nonclientmetrics
  353. // get stored data string
  354. uret = (UINT) GetPrivateProfileString((LPTSTR)szMetrics, (LPTSTR)szNCM,
  355. (LPTSTR)szNULL,
  356. (LPTSTR)pValue, MAX_VALUELEN,
  357. (LPTSTR)szCurThemeFile);
  358. Assert(uret, TEXT("problem getting stored nonclient metrics before setting\n"));
  359. // if we somehow come up with no non-client metrics in the theme, just
  360. // PUNT and leave cur settings
  361. if (!(*pValue))
  362. return; // easy no work to do EXIT
  363. // translate stored data string to NONCLIENTMETRICS bytes
  364. WriteBytesToBuffer((LPTSTR)pValue); // char str read from and binary bytes
  365. // written to pValue. It's OK.
  366. // get it into NONCLIENTMETRICS structure for ease of use and safety
  367. #ifdef UNICODE
  368. // NONCLIENTMETRICS are stored in ANSI format in the Theme file so
  369. // we need to convert them to UNICODE
  370. ConvertNCMetricsToWIDE((LPNONCLIENTMETRICSA)pValue, (LPNONCLIENTMETRICSW)&ncmStored);
  371. #else
  372. // No UNICODE so no need to convert NONCLIENTMETRICS...
  373. ncmStored = *((LPNONCLIENTMETRICS)pValue);
  374. #endif
  375. //
  376. // Combine the cur with the requested saved info here and now
  377. // Cur metrics are the default, overridden for fields requested
  378. // by user by new info from metrics stored with the theme.
  379. //
  380. // init
  381. ncmCur.cbSize = sizeof(NONCLIENTMETRICS); // paranoid
  382. // what we reset if the user checks Font names and styles
  383. if (bFonts) {
  384. // only (some) font information
  385. TransmitFontCharacteristics(&(ncmCur.lfCaptionFont), &(ncmStored.lfCaptionFont),
  386. TFC_STYLE);
  387. TransmitFontCharacteristics(&(ncmCur.lfSmCaptionFont), &(ncmStored.lfSmCaptionFont),
  388. TFC_STYLE);
  389. TransmitFontCharacteristics(&(ncmCur.lfMenuFont), &(ncmStored.lfMenuFont),
  390. TFC_STYLE);
  391. TransmitFontCharacteristics(&(ncmCur.lfStatusFont), &(ncmStored.lfStatusFont),
  392. TFC_STYLE);
  393. TransmitFontCharacteristics(&(ncmCur.lfMessageFont), &(ncmStored.lfMessageFont),
  394. TFC_STYLE);
  395. }
  396. // what we reset if the user checks Font and window si&zes
  397. if (bBorders) {
  398. // fonts
  399. TransmitFontCharacteristics(&(ncmCur.lfCaptionFont), &(ncmStored.lfCaptionFont),
  400. TFC_SIZE);
  401. TransmitFontCharacteristics(&(ncmCur.lfSmCaptionFont), &(ncmStored.lfSmCaptionFont),
  402. TFC_SIZE);
  403. TransmitFontCharacteristics(&(ncmCur.lfMenuFont), &(ncmStored.lfMenuFont),
  404. TFC_SIZE);
  405. TransmitFontCharacteristics(&(ncmCur.lfStatusFont), &(ncmStored.lfStatusFont),
  406. TFC_SIZE);
  407. TransmitFontCharacteristics(&(ncmCur.lfMessageFont), &(ncmStored.lfMessageFont),
  408. TFC_SIZE);
  409. // window elements sizes
  410. ncmCur.iBorderWidth = ncmStored.iBorderWidth;
  411. ncmCur.iScrollWidth = ncmStored.iScrollWidth;
  412. ncmCur.iScrollHeight = ncmStored.iScrollHeight;
  413. ncmCur.iCaptionWidth = ncmStored.iCaptionWidth;
  414. ncmCur.iCaptionHeight = ncmStored.iCaptionHeight;
  415. ncmCur.iSmCaptionWidth = ncmStored.iSmCaptionWidth;
  416. ncmCur.iSmCaptionHeight = ncmStored.iSmCaptionHeight;
  417. ncmCur.iMenuWidth = ncmStored.iMenuWidth;
  418. ncmCur.iMenuHeight = ncmStored.iMenuHeight;
  419. }
  420. //
  421. // Phew! Now set it in the system live...
  422. uret = (UINT) SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(ncmCur),
  423. (void far *)(LPNONCLIENTMETRICS)&ncmCur,
  424. // send change at end of theme application
  425. SPIF_UPDATEINIFILE);
  426. Assert(uret, TEXT("problem setting nonclient metrics in cur system!!\n"));
  427. }
  428. //
  429. // TransmitFontCharacteristics
  430. //
  431. // This is actually a pretty key function. See, font characteristics are
  432. // all set together: a LOGFONT has name and style and size info all in one.
  433. // But when you are setting all the nonclient metrics like window caption
  434. // and menu size, you need to stretch the font sizes with it. But we give the
  435. // user a choice of changing window sizes without "changing" the font; i.e.
  436. // without applying a new font name and style from the theme.
  437. //
  438. // So we need to be able to pick apart the name and style from the size
  439. // characteristics. And here it is.
  440. //
  441. // Really just a helper routine for the above function, so we don't have all
  442. // this gunk inline five times.
  443. //
  444. VOID TransmitFontCharacteristics(PLOGFONT plfDst, PLOGFONT plfSrc, int iXmit)
  445. {
  446. switch (iXmit) {
  447. case TFC_SIZE:
  448. plfDst->lfHeight = plfSrc->lfHeight;
  449. plfDst->lfWidth = plfSrc->lfWidth;
  450. break;
  451. case TFC_STYLE:
  452. plfDst->lfEscapement = plfSrc->lfEscapement;
  453. plfDst->lfOrientation = plfSrc->lfOrientation;
  454. plfDst->lfWeight = plfSrc->lfWeight;
  455. plfDst->lfItalic = plfSrc->lfItalic;
  456. plfDst->lfUnderline = plfSrc->lfUnderline;
  457. plfDst->lfStrikeOut = plfSrc->lfStrikeOut;
  458. plfDst->lfCharSet = plfSrc->lfCharSet;
  459. plfDst->lfOutPrecision = plfSrc->lfOutPrecision;
  460. plfDst->lfClipPrecision = plfSrc->lfClipPrecision;
  461. plfDst->lfQuality = plfSrc->lfQuality;
  462. plfDst->lfPitchAndFamily = plfSrc->lfPitchAndFamily;
  463. lstrcpy((LPTSTR)plfDst->lfFaceName,
  464. (LPTSTR)plfSrc->lfFaceName);
  465. break;
  466. }
  467. }
  468. #ifdef UNICODE
  469. VOID ConvertIconMetricsToANSI(LPICONMETRICS wIM, LPICONMETRICSA aIM)
  470. {
  471. ZeroMemory(aIM, sizeof(aIM));
  472. aIM->cbSize = sizeof(aIM);
  473. aIM->iHorzSpacing = wIM->iHorzSpacing;
  474. aIM->iVertSpacing = wIM->iVertSpacing;
  475. aIM->iTitleWrap = wIM->iTitleWrap;
  476. ConvertLogFontToANSI(&wIM->lfFont, &aIM->lfFont);
  477. return;
  478. }
  479. VOID ConvertIconMetricsToWIDE(LPICONMETRICSA aIM, LPICONMETRICSW wIM)
  480. {
  481. ZeroMemory(wIM, sizeof(wIM));
  482. wIM->cbSize = sizeof(wIM);
  483. wIM->iHorzSpacing = aIM->iHorzSpacing;
  484. wIM->iVertSpacing = aIM->iVertSpacing;
  485. wIM->iTitleWrap = aIM->iTitleWrap;
  486. ConvertLogFontToWIDE(&aIM->lfFont, &wIM->lfFont);
  487. return;
  488. }
  489. VOID ConvertNCMetricsToANSI(LPNONCLIENTMETRICSW wNCM, LPNONCLIENTMETRICSA aNCM)
  490. {
  491. ZeroMemory(aNCM, sizeof(aNCM));
  492. aNCM->cbSize = sizeof(aNCM);
  493. aNCM->iBorderWidth = wNCM->iBorderWidth;
  494. aNCM->iScrollWidth = wNCM->iScrollWidth;
  495. aNCM->iScrollHeight = wNCM->iScrollHeight;
  496. aNCM->iCaptionWidth = wNCM->iCaptionWidth;
  497. aNCM->iCaptionHeight = wNCM->iCaptionHeight;
  498. ConvertLogFontToANSI(&wNCM->lfCaptionFont, &aNCM->lfCaptionFont);
  499. aNCM->iSmCaptionWidth = wNCM->iSmCaptionWidth;
  500. aNCM->iSmCaptionHeight = wNCM->iSmCaptionHeight;
  501. ConvertLogFontToANSI(&wNCM->lfSmCaptionFont, &aNCM->lfSmCaptionFont);
  502. aNCM->iMenuWidth = wNCM->iMenuWidth;
  503. aNCM->iMenuHeight = wNCM->iMenuHeight;
  504. ConvertLogFontToANSI(&wNCM->lfMenuFont, &aNCM->lfMenuFont);
  505. ConvertLogFontToANSI(&wNCM->lfStatusFont, &aNCM->lfStatusFont);
  506. ConvertLogFontToANSI(&wNCM->lfMessageFont, &aNCM->lfMessageFont);
  507. return;
  508. }
  509. VOID ConvertNCMetricsToWIDE(LPNONCLIENTMETRICSA aNCM, LPNONCLIENTMETRICSW wNCM)
  510. {
  511. ZeroMemory(wNCM, sizeof(wNCM));
  512. wNCM->cbSize = sizeof(wNCM);
  513. wNCM->iBorderWidth = aNCM->iBorderWidth;
  514. wNCM->iScrollWidth = aNCM->iScrollWidth;
  515. wNCM->iScrollHeight = aNCM->iScrollHeight;
  516. wNCM->iCaptionWidth = aNCM->iCaptionWidth;
  517. wNCM->iCaptionHeight = aNCM->iCaptionHeight;
  518. ConvertLogFontToWIDE(&aNCM->lfCaptionFont, &wNCM->lfCaptionFont);
  519. wNCM->iSmCaptionWidth = aNCM->iSmCaptionWidth;
  520. wNCM->iSmCaptionHeight = aNCM->iSmCaptionHeight;
  521. ConvertLogFontToWIDE(&aNCM->lfSmCaptionFont, &wNCM->lfSmCaptionFont);
  522. wNCM->iMenuWidth = aNCM->iMenuWidth;
  523. wNCM->iMenuHeight = aNCM->iMenuHeight;
  524. ConvertLogFontToWIDE(&aNCM->lfMenuFont, &wNCM->lfMenuFont);
  525. ConvertLogFontToWIDE(&aNCM->lfStatusFont, &wNCM->lfStatusFont);
  526. ConvertLogFontToWIDE(&aNCM->lfMessageFont, &wNCM->lfMessageFont);
  527. return;
  528. }
  529. VOID ConvertLogFontToANSI(LPLOGFONTW wLF, LPLOGFONTA aLF)
  530. {
  531. UINT uCodePage;
  532. uCodePage = _getmbcp();
  533. ZeroMemory(aLF, sizeof(aLF));
  534. aLF->lfHeight = wLF->lfHeight;
  535. aLF->lfWidth = wLF->lfWidth;
  536. aLF->lfEscapement = wLF->lfEscapement;
  537. aLF->lfOrientation = wLF->lfOrientation;
  538. aLF->lfWeight = wLF->lfWeight;
  539. aLF->lfItalic = wLF->lfItalic;
  540. aLF->lfUnderline = wLF->lfUnderline;
  541. aLF->lfStrikeOut = wLF->lfStrikeOut;
  542. aLF->lfCharSet = wLF->lfCharSet;
  543. aLF->lfOutPrecision = wLF->lfOutPrecision;
  544. aLF->lfClipPrecision = wLF->lfClipPrecision;
  545. aLF->lfQuality = wLF->lfQuality;
  546. aLF->lfPitchAndFamily = wLF->lfPitchAndFamily;
  547. WideCharToMultiByte(uCodePage, 0, wLF->lfFaceName, -1,
  548. aLF->lfFaceName, LF_FACESIZE, NULL, NULL);
  549. return;
  550. }
  551. VOID ConvertLogFontToWIDE(LPLOGFONTA aLF, LPLOGFONTW wLF)
  552. {
  553. UINT uCodePage;
  554. uCodePage = _getmbcp();
  555. ZeroMemory(wLF, sizeof(wLF));
  556. wLF->lfHeight = aLF->lfHeight;
  557. wLF->lfWidth = aLF->lfWidth;
  558. wLF->lfEscapement = aLF->lfEscapement;
  559. wLF->lfOrientation = aLF->lfOrientation;
  560. wLF->lfWeight = aLF->lfWeight;
  561. wLF->lfItalic = aLF->lfItalic;
  562. wLF->lfUnderline = aLF->lfUnderline;
  563. wLF->lfStrikeOut = aLF->lfStrikeOut;
  564. wLF->lfCharSet = aLF->lfCharSet;
  565. wLF->lfOutPrecision = aLF->lfOutPrecision;
  566. wLF->lfClipPrecision = aLF->lfClipPrecision;
  567. wLF->lfQuality = aLF->lfQuality;
  568. wLF->lfPitchAndFamily = aLF->lfPitchAndFamily;
  569. MultiByteToWideChar(uCodePage, 0, aLF->lfFaceName, -1,
  570. wLF->lfFaceName, LF_FACESIZE);
  571. return;
  572. }
  573. #endif // UNICODE