home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.tools
- From: chris@chrism.demon.co.uk (Chris Marriott)
- Path: sparky!uunet!pipex!demon!chrism.demon.co.uk!chris
- Subject: Re: printing
- Distribution: world
- References: <1658@bdrc.bdrc.bd.com>
- Organization: None
- Reply-To: chris@chrism.demon.co.uk
- X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
- Lines: 54
- Date: Fri, 18 Dec 1992 21:15:45 +0000
- Message-ID: <724713345snz@chrism.demon.co.uk>
- Sender: usenet@demon.co.uk
-
- In article <1658@bdrc.bdrc.bd.com> jcl@bdrc.bd.com writes:
-
- >How does one print using OWL? The Borland documentation is very confusing
- >to me (perhaps because I'm a windows newbie). It seems to me that
- >all I would need to do is instead of writing to a display context
- >I would write to device context instead. Windows should take
- >care of everything else for me. Thus, if I had a function that produced
- >some output, I would send it a device context or a display context
- >depending on where I wanted the output to go. Am I being naive?
- >
-
- That's exactly right. Just write your drawing code to draw on a DC.
- In most cases the code shouldn't care if it's drawing on the screen,
- to a printer, a metafile, or whatever. In the rare cases you DO need
- to know, call "GetDeviceCaps" to find out.
-
- >Another question is how to I get a device context? The CreateDC function
- >needs the driver name, the device name, and so on. Why do I need to
- >supply these things? I just want output to go to the default printer.
- >
-
- The simple way in Window 3.1 is to use the printer common dialog box. Just
- call the "PrintDlg" function, and it returns you a DC. Easy.
-
- >Would some kind soul send me a minimal program to print the phrase
- >"Hello, world!" via Windows?
- >
-
- I don't have any code to hand, but, in its simplest form all you do is:
-
- ... Get Printer DC from common dialog function .....
-
- StartDoc(....);
- StartPage(.....);
-
- ... draw to printer DC ....
-
- EndPage( ... );
- EndDoc( ... );
-
- DeleteDC( hPrinter );
-
- If you have multiple pages to print, just have StartPage()/EndPage() around
- each one.
-
- Chris
- --
- --------------------------------------------------------------------------
- | Chris Marriott | chris@chrism.demon.co.uk |
- | Warrington, UK | BIX: cmarriott |
- | (Still awaiting inspiration | CIX: cmarriott |
- | for a witty .sig .... ) | CompuServe: 100113,1140 |
- --------------------------------------------------------------------------
-
-