Solved

accessing printer stream in c++ for windows

Posted on 1997-01-30
1
496 Views
Last Modified: 2006-11-17
I've got what's probably a really easy question,
but I can't seem to find an answer in several different
books...can someone tell me how to send a stream to the
printer in borland c++ for windows?
 I've tried:
#define printer "LPT1"
  and
#define printer "PRN"
 even
#define printer "PRN:LPT1"
 then
ofstream outf;
outf.open(printer);  c++ seems to recognize PRN and LPT1 as valid
outf <<...           constants--no errors on run
                      but output is sent to screen(window).
the text says that stdio.h has a stream called stdprn
and i've tried to use
 fprintf(stdprn,"this is a test");
just to try that, and it goes to screen also.
The least capability I need is to be able to create a file then
print hard copy from within the program...I would like to be able
to send individual lines to printer for headers or summary that I
don't want in the actual file.
  Pardon me if I've missed something obvious.....
BTW this is windows 3.11 and borland c++4.52 (I also have turboc++3.1)

                thanks in advance
                    kevin
0
Comment
Question by:kellis
1 Comment
 

Accepted Solution

by:
cstaley earned 50 total points
ID: 1161865
You don't say whether you are using an EasyWin application or not.  I assume you are.  I'm not certain, but I don't believe there is any easy way to do printer output.  The only way I've been able to do printer output under Windows is to use TPrinter and its associated classes.  The problem is that the printer is a spooled device, and Windows does *not* like you to take direct control of it.  Instead, you are expected to interact with the print manager.  I would have expected Borland to supply you with a "fake IO stream" under EasyWin that would take care of interacting with the print manager, but apparently they don't.

Clint


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 267
Unresolved External Symbols 3 127
Create a path if not exists 7 105
I could not set window to top 4 40
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question