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.

147 lines
3.7 KiB

  1. /* File: D:\WACKER\tdll\fontdlg.c (Created: 14-Jan-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 5 $
  7. * $Date: 3/28/02 9:37a $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include "stdtyp.h"
  12. #include "globals.h"
  13. #include "print.hh"
  14. #include "session.h"
  15. #include "misc.h"
  16. #include "term.h"
  17. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. * FUNCTION:
  19. * DisplayFontDialog
  20. *
  21. * DESCRIPTION:
  22. * Invokes the common dialog box for font selection.
  23. *
  24. * ARGUMENTS:
  25. * HWND hwnd - handle to parent dialog window.
  26. *
  27. * RETURNS:
  28. * void
  29. *
  30. */
  31. void DisplayFontDialog(const HSESSION hSession, BOOL fPrinterFont )
  32. {
  33. LOGFONT lf, lfOld;
  34. CHOOSEFONT chf;
  35. BOOL fRet;
  36. const HWND hwnd = sessQueryHwnd(hSession);
  37. HHPRINT hhPrint = (HHPRINT) sessQueryPrintHdl(hSession);
  38. //
  39. // setup font structure
  40. //
  41. ZeroMemory(&chf, sizeof(CHOOSEFONT));
  42. chf.lStructSize = sizeof(CHOOSEFONT);
  43. chf.hwndOwner = hwnd;
  44. chf.lpLogFont = &lf;
  45. chf.rgbColors = RGB(0, 0, 0);
  46. chf.lCustData = 0;
  47. chf.hInstance = glblQueryHinst();
  48. chf.lpszStyle = (LPTSTR)0;
  49. chf.nSizeMin = 1;
  50. chf.nSizeMax = 469; // Largest that will still display. REV: 3/28/2002
  51. chf.Flags = CF_NOVERTFONTS | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE;
  52. //
  53. // set up for terminal font selection
  54. //
  55. if ( !fPrinterFont )
  56. {
  57. SendMessage(sessQueryHwndTerminal(hSession), WM_TERM_GETLOGFONT, 0,
  58. (LPARAM)&lf);
  59. chf.nFontType = SCREEN_FONTTYPE;
  60. chf.hDC = GetDC(hwnd);
  61. chf.Flags |= CF_SCREENFONTS | CF_FIXEDPITCHONLY;
  62. lfOld = lf;
  63. fRet = ChooseFont(&chf);
  64. ReleaseDC(hwnd, chf.hDC);
  65. }
  66. //
  67. // set up for printer font selection
  68. //
  69. else
  70. {
  71. hhPrint->hDC = printCtrlCreateDC((HPRINT)hhPrint);
  72. lf = hhPrint->lf;
  73. chf.nFontType = PRINTER_FONTTYPE;
  74. chf.hDC = hhPrint->hDC;
  75. chf.Flags |= CF_EFFECTS | CF_PRINTERFONTS;
  76. lfOld = lf;
  77. fRet = ChooseFont(&chf);
  78. }
  79. //
  80. // Save any changes that were made
  81. //
  82. if (fRet && memcmp(&lf, &lfOld, sizeof(LOGFONT)) != 0)
  83. {
  84. const HWND hwndTerm = sessQueryHwndTerminal(hSession);
  85. if ( !fPrinterFont )
  86. {
  87. SendMessage(hwndTerm, WM_TERM_SETLOGFONT, 0, (LPARAM)&lf);
  88. RefreshTermWindow(hwndTerm);
  89. }
  90. else
  91. {
  92. //
  93. // save the dialog returned log font in the print handle and also
  94. // save the selected point size. This is done since the font point
  95. // size returned by the dialog is is not correct when used for
  96. // printing. However the dialog settings must be saved for the
  97. // next time the dialog is displayed. The correct font is calculated
  98. // based on the save point size and face name before printing by the
  99. // printCreatePointFont function.
  100. //
  101. hhPrint->iFontPointSize = chf.iPointSize;
  102. hhPrint->lf = lf;
  103. lf.lfHeight = chf.iPointSize;
  104. //
  105. // if char set is ansi change to oem to get line draw characters
  106. //
  107. if ( lf.lfCharSet == ANSI_CHARSET )
  108. {
  109. lf.lfCharSet = OEM_CHARSET;
  110. }
  111. }
  112. //
  113. // get rid of the printer device context if one was created
  114. //
  115. if ( fPrinterFont )
  116. {
  117. printCtrlDeleteDC((HPRINT)hhPrint);
  118. }
  119. }
  120. return;
  121. }