Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

accessing printer stream in c++ for windows

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

837 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