Solved

Printing a text file with a MFC application

Posted on 1998-09-10
3
523 Views
Last Modified: 2013-11-20
I have a MFC application that when the user selects the menu item <PRINT REPORT> it writes a lot of formatted text to a text file. I want the program to then send the file to the default printer to be printed.  How do I do that?

I realize this is not the best way to a print a file with a MFC application.  However, I already have the text file formatted and would like to simply print that text file.
0
Comment
Question by:scs1
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1322062
The easiest way is to launch Notepad to print it. For example,

::ShellExecute(hWnd, _T("print"), _T("mydoc.txt"), NULL, NULL, SW_HIDE);
0
 

Author Comment

by:scs1
ID: 1322063
Thank you very much for your help. However, I do not know how to set the windows handler (hWnd) to the notepad.  When I run the program with the line above it tries to print, but an error box pops up saying that the notepad handler is invalid.  How do I set it?
0
 

Author Comment

by:scs1
ID: 1322064
Forget the previous comment.  My problem was related to a printer setup problem with my computer.  I have corrected the problem and everything works great.  Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now