Solved

accessing printer stream in c++ for windows

Posted on 1997-01-30
1
488 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

803 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