home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / mswindo / programm / misc / 1495 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  1.7 KB

  1. From: Monroe.Thomas@ttlg.UUCP (Monroe Thomas)
  2. Sender: postmaster@ttlg.UUCP
  3. Path: sparky!uunet!wupost!gumby!destroyer!ubc-cs!alberta!ttlg!postmaster
  4. Newsgroups: comp.os.ms-windows.programmer.misc
  5. Subject: Printer Fonts
  6. Message-ID: <714807912.3@ttlg.ttlg.UUCP>
  7. Date: 25 Aug 92  22:11:06 mst
  8. Lines: 46
  9.  
  10. DW>I just received Quick C for Windows and am attempting to write my
  11.   >first application.  I have managed to print out my data with an abort dialog
  12.   >box.  I am trying to figure out how to change the printer font.  I have
  13.   >Programming Windows by Charles Petzold and I am unable to figure out how to
  14.   >change the Printer Font.  Does anyone know of another book or have some
  15.   >sample code of how to do this? Thank you.
  16.  
  17.  
  18. Sure, you need to fill in the attributes of a LOGFONT structure,
  19. and then select that font into the printer device context.
  20.  
  21. Eg.
  22.  
  23.     HFONT   hfontPrinter;
  24.     HFONT   hfontOld;
  25.     LOGFONT lf;
  26.  
  27.     // initialize structure to zero, fill in attributes as desired
  28.     memset(&lf, 0, sizeof(LOGFONT));
  29.     lf.lfWeight = FW_NORMAL;
  30.     lf.lfHeight = -10;
  31.     lstrcpy(lf.lfFaceName, "MS Sans Serif");
  32.  
  33.     // get handle to new font
  34.     hfontPrinter = CreateFontIndirect(&lf);
  35.  
  36.     // select font into printer device context
  37.     // when doing so, hfontOld will contain
  38.     // handle to old printer font
  39.     hfontOld = SelectObject(hdcPrinter, hfontPrinter);
  40.  
  41.     ... // printing code //
  42.  
  43.     // put old font back into printer DC, and delete new font
  44.     // object since it is no longer needed
  45.     SelectObject(hdcPrinter, hfontOld);
  46.     DeleteObject(hfontPrinter);
  47.  
  48.     ... // other clean up code
  49.  
  50.  
  51. -Monroe
  52.  
  53.  * OLX 2.2 * MT: Those are my initials, not the state of my head!
  54.  
  55.  * Origin: Through the Looking Glass (42:100/14)
  56.