home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / tools / 1770 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.5 KB  |  69 lines

  1. Newsgroups: comp.os.ms-windows.programmer.tools
  2. From: chris@chrism.demon.co.uk (Chris Marriott)
  3. Path: sparky!uunet!pipex!demon!chrism.demon.co.uk!chris
  4. Subject: Re: printing 
  5. Distribution: world
  6. References: <1658@bdrc.bdrc.bd.com>
  7. Organization: None
  8. Reply-To: chris@chrism.demon.co.uk
  9. X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
  10. Lines: 54
  11. Date: Fri, 18 Dec 1992 21:15:45 +0000
  12. Message-ID: <724713345snz@chrism.demon.co.uk>
  13. Sender: usenet@demon.co.uk
  14.  
  15. In article <1658@bdrc.bdrc.bd.com> jcl@bdrc.bd.com writes:
  16.  
  17. >How does one print using OWL?  The Borland documentation is very confusing
  18. >to me (perhaps because I'm a windows newbie).  It seems to me that
  19. >all I would need to do is instead of writing to a display context
  20. >I would write to device context instead.  Windows should take
  21. >care of everything else for me.  Thus, if I had a function that produced
  22. >some output, I would send it a device context or a display context
  23. >depending on where I wanted the output to go.  Am I being naive? 
  24. >
  25.  
  26. That's exactly right.  Just write your drawing code to draw on a DC.
  27. In most cases the code shouldn't care if it's drawing on the screen,
  28. to a printer, a metafile, or whatever.  In the rare cases you DO need
  29. to know, call "GetDeviceCaps" to find out.
  30.  
  31. >Another question is how to I get a device context?  The CreateDC function
  32. >needs the driver name, the device name, and so on.  Why do I need to
  33. >supply these things?  I just want output to go to the default printer.
  34. >
  35.  
  36. The simple way in Window 3.1 is to use the printer common dialog box.  Just
  37. call the "PrintDlg" function, and it returns you a DC.  Easy.
  38.  
  39. >Would some kind soul send me a minimal program to print the phrase
  40. >"Hello, world!" via Windows?
  41. >
  42.  
  43. I don't have any code to hand, but, in its simplest form all you do is:
  44.  
  45.     ... Get Printer DC from common dialog function .....
  46.  
  47.     StartDoc(....);
  48.     StartPage(.....);
  49.  
  50.     ... draw to printer DC ....
  51.  
  52.     EndPage( ... );
  53.     EndDoc( ... );
  54.  
  55.     DeleteDC( hPrinter );
  56.  
  57. If you have multiple pages to print, just have StartPage()/EndPage() around
  58. each one.
  59.  
  60. Chris
  61. -- 
  62. --------------------------------------------------------------------------
  63. | Chris Marriott                           | chris@chrism.demon.co.uk    |
  64. | Warrington, UK                           | BIX: cmarriott              |
  65. | (Still awaiting inspiration              | CIX: cmarriott              |
  66. |  for a witty .sig .... )                 | CompuServe: 100113,1140     |
  67. --------------------------------------------------------------------------
  68.  
  69.