Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing without MFC

Status
Not open for further replies.

Kherozen

Programmer
Jun 5, 2003
129
CA
Hi,
I've build a small application(Console Application) that build a report and save it to a textfile and at the end, I want to automaticly print that file. SO I tried System("print C:\report.txt"); and I got the dos prompt saying "C:\report.txt is currently being printed" but it never print. I guess the problem is not C++ but the print command because I tried it directly in Dos and it doesn't work either. So I was wondering if anyone know why it doesn't work and/or another way to print document in a console application.

thx.



jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
Well first of All
that function is not define so I tried to look into the MSDN and it said shellapi.h , I tried to include that , That give me errors inside of the shellapi.h , so I guess that's not the good thing to do, can you be more precise please like what am I suppose to use as HWND in a console application?



jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
>> so I guess that's not the good thing to do

guessing in C/C++ development is not the good thing to do
Code:
#include <windows.h>
#include <shellapi.h>

ShellExecute(NULL, &quot;print&quot;, &quot;c:\\myfile.txt&quot;, NULL, NULL, SW_HIDE);

-pete
 
This is why I was asking,

Thanks It work ... do you know how to print in landscape?



jul ^_^
&quot;Computer Science is no more about computers than astronomy is about telescopes&quot;
E. W. Dijkstra.
 
>> Thanks It work ... do you know how to print in landscape?

Don't think you can do that with ShellExecute. You need to actually do windows printing API to gain any control over attributes like that. See the Platform SDK GDI functions like OpenPrinter(), StartDocPrinter() etc.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top