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.

96 lines
2.1 KiB

  1. //Copyright (c) 1998 - 2001 Microsoft Corporation
  2. #include "fonts.h"
  3. VOID
  4. SetControlFont(
  5. IN HFONT hFont,
  6. IN HWND hwnd,
  7. IN INT nId
  8. )
  9. {
  10. if( hFont )
  11. {
  12. HWND hwndControl = GetDlgItem(hwnd, nId);
  13. if( hwndControl )
  14. {
  15. SetWindowFont(hwndControl, hFont, TRUE);
  16. }
  17. }
  18. }
  19. VOID
  20. SetupFonts(
  21. IN HINSTANCE hInstance,
  22. IN HWND hwnd,
  23. IN HFONT *pBigBoldFont,
  24. IN HFONT *pBoldFont
  25. )
  26. {
  27. //
  28. // Create the fonts we need based on the dialog font
  29. //
  30. NONCLIENTMETRICS ncm = {0};
  31. ncm.cbSize = sizeof(ncm);
  32. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  33. LOGFONT BigBoldLogFont = ncm.lfMessageFont;
  34. LOGFONT BoldLogFont = ncm.lfMessageFont;
  35. //
  36. // Create Big Bold Font and Bold Font
  37. //
  38. BigBoldLogFont.lfWeight = FW_BOLD;
  39. BoldLogFont.lfWeight = FW_BOLD;
  40. TCHAR FontSizeString[MAX_PATH];
  41. INT FontSize;
  42. //
  43. // Load size and name from resources, since these may change
  44. // from locale to locale based on the size of the system font, etc.
  45. //
  46. if(!LoadString(hInstance,IDS_LARGEFONTNAME,BigBoldLogFont.lfFaceName,LF_FACESIZE))
  47. {
  48. lstrcpy(BigBoldLogFont.lfFaceName,TEXT("MS Shell Dlg"));
  49. }
  50. if(LoadString(hInstance,IDS_LARGEFONTSIZE,FontSizeString,sizeof(FontSizeString)/sizeof(TCHAR)))
  51. {
  52. FontSize = _tcstoul( FontSizeString, NULL, 10 );
  53. }
  54. else
  55. {
  56. FontSize = 12;
  57. }
  58. HDC hdc = GetDC( hwnd );
  59. if( hdc )
  60. {
  61. BigBoldLogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * FontSize / 72);
  62. *pBigBoldFont = CreateFontIndirect(&BigBoldLogFont);
  63. *pBoldFont = CreateFontIndirect(&BoldLogFont);
  64. ReleaseDC(hwnd,hdc);
  65. }
  66. }
  67. VOID
  68. DestroyFonts(
  69. IN HFONT hBigBoldFont,
  70. IN HFONT hBoldFont
  71. )
  72. {
  73. if( hBigBoldFont )
  74. {
  75. DeleteObject( hBigBoldFont );
  76. }
  77. if( hBoldFont )
  78. {
  79. DeleteObject( hBoldFont );
  80. }
  81. }