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.

160 lines
4.7 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "DlgFonts.h"
  6. #include "accwiz.h" // for g_Options
  7. HFONT BigBoldFont = NULL;
  8. HFONT BoldFont = NULL;
  9. HFONT BigFont = NULL;
  10. // Helper function
  11. void SetControlFont(HFONT hFont, HWND hwnd, int nId)
  12. {
  13. if(!hFont)
  14. return;
  15. HWND hwndControl = GetDlgItem(hwnd, nId);
  16. if(!hwndControl)
  17. return;
  18. SetWindowFont(hwndControl, hFont, TRUE);
  19. }
  20. void SetupFonts(HWND hwnd)
  21. {
  22. // Only execute this code once
  23. static BOOL bOneTime = TRUE;
  24. if(bOneTime)
  25. bOneTime = FALSE;
  26. else
  27. return;
  28. // Create the fonts we need based on the dialog font
  29. NONCLIENTMETRICS ncm;
  30. memset(&ncm, 0, sizeof(ncm));
  31. ncm.cbSize = sizeof(ncm);
  32. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  33. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  34. LOGFONT BoldLogFont = ncm.lfMessageFont;
  35. LOGFONT BigLogFont = ncm.lfMessageFont;
  36. // Create Big Bold Font and Bold Font
  37. BigBoldLogFont.lfWeight = FW_BOLD;
  38. BoldLogFont.lfWeight = FW_BOLD;
  39. BigLogFont.lfWeight = FW_NORMAL;
  40. TCHAR FontSizeString[24];
  41. int FontSizeBigBold;
  42. int FontSizeBold;
  43. int FontSizeBig;
  44. //
  45. // Load size and name from resources, since these may change
  46. // from locale to locale based on the size of the system font, etc.
  47. //
  48. BigBoldLogFont.lfCharSet = g_Options.m_lfCharSet;
  49. BoldLogFont.lfCharSet = g_Options.m_lfCharSet;
  50. BigLogFont.lfCharSet = g_Options.m_lfCharSet;
  51. if(!LoadString(g_hInstDll,IDS_BIGBOLDFONTNAME,BigBoldLogFont.lfFaceName,LF_FACESIZE)) {
  52. lstrcpy(BigBoldLogFont.lfFaceName,TEXT("MS Serif"));
  53. }
  54. if(!LoadString(g_hInstDll,IDS_BOLDFONTNAME,BoldLogFont.lfFaceName,LF_FACESIZE)) {
  55. lstrcpy(BoldLogFont.lfFaceName,TEXT("MS Serif"));
  56. }
  57. if(!LoadString(g_hInstDll,IDS_BIGFONTNAME,BigLogFont.lfFaceName,LF_FACESIZE)) {
  58. lstrcpy(BigLogFont.lfFaceName,TEXT("MS Serif"));
  59. }
  60. if(LoadString(g_hInstDll,IDS_BIGBOLDFONTSIZE,FontSizeString,sizeof(FontSizeString)/sizeof(TCHAR))) {
  61. FontSizeBigBold = _tcstoul(FontSizeString,NULL,10);
  62. } else {
  63. FontSizeBigBold = 16;
  64. }
  65. if(LoadString(g_hInstDll,IDS_BOLDFONTSIZE,FontSizeString,sizeof(FontSizeString)/sizeof(TCHAR))) {
  66. FontSizeBold = _tcstoul(FontSizeString,NULL,10);
  67. } else {
  68. FontSizeBold = 8;
  69. }
  70. if(LoadString(g_hInstDll,IDS_BIGFONTSIZE,FontSizeString,sizeof(FontSizeString)/sizeof(TCHAR))) {
  71. FontSizeBig = _tcstoul(FontSizeString,NULL,10);
  72. } else {
  73. FontSizeBig = 16;
  74. }
  75. HDC hdc;
  76. if(hdc = GetDC(hwnd)) {
  77. BigBoldLogFont.lfHeight = 0 - (int)((float)GetDeviceCaps(hdc,LOGPIXELSY) * (float)FontSizeBigBold / (float)72 + (float).5);
  78. BoldLogFont.lfHeight = 0 - (int)((float)GetDeviceCaps(hdc,LOGPIXELSY) * (float)FontSizeBold / (float)72 + (float).5);
  79. BigLogFont.lfHeight = 0 - (int)((float)GetDeviceCaps(hdc,LOGPIXELSY) * (float)FontSizeBig / (float)72 + (float).5);
  80. BigBoldFont = CreateFontIndirect(&BigBoldLogFont);
  81. BoldFont = CreateFontIndirect(&BoldLogFont);
  82. BigFont = CreateFontIndirect(&BigLogFont);
  83. ReleaseDC(hwnd,hdc);
  84. }
  85. }
  86. void DialogFonts_InitWizardPage(
  87. IN HWND hwndWizardPage
  88. )
  89. {
  90. SetupFonts(hwndWizardPage);
  91. // If we are going to change the fonts of all wizard pages,
  92. // we can't allow the user to go back and change the size
  93. // they picked. This is because this function is only called
  94. // once for each page.
  95. /*
  96. if(-1 != g_Options.m_nMinimalFontSize)
  97. {
  98. */
  99. HWND hwndChild = GetTopWindow(hwndWizardPage);
  100. do
  101. {
  102. int nId = GetDlgCtrlID(hwndChild);
  103. switch(nId)
  104. {
  105. case IDC_BOLDTITLE:
  106. SetControlFont(BoldFont, hwndWizardPage, IDC_BOLDTITLE);
  107. break;
  108. case IDC_BIGBOLDTITLE:
  109. SetControlFont(BigBoldFont, hwndWizardPage, IDC_BIGBOLDTITLE);
  110. break;
  111. case IDC_BIGTITLE:
  112. SetControlFont(BigFont, hwndWizardPage, IDC_BIGTITLE);
  113. break;
  114. #if 0 // This used to be for the icon size page
  115. case IDC_STATICNORMAL:
  116. SetWindowFont(hwndChild, g_Options.GetClosestMSSansSerif(8), TRUE);
  117. break;
  118. case IDC_STATICLARGE:
  119. SetWindowFont(hwndChild, g_Options.GetClosestMSSansSerif(12), TRUE);
  120. break;
  121. case IDC_STATICEXTRALARGE:
  122. SetWindowFont(hwndChild, g_Options.GetClosestMSSansSerif(18), TRUE);
  123. break;
  124. #endif
  125. default:
  126. #if 0 // We decided that we weren't going to resize the fonts in the dialog
  127. // DON'T go above 12 points for the dialog fonts
  128. SetWindowFont(hwndChild, g_Options.GetClosestMSSansSerif(min(12, g_Options.m_nMinimalFontSize)), TRUE);
  129. #endif
  130. break;
  131. }
  132. }
  133. while(hwndChild = GetNextWindow(hwndChild, GW_HWNDNEXT));
  134. }