Solved

Printing a text file with a MFC application

Posted on 1998-09-10
3
519 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

11 Experts available now in Live!

Get 1:1 Help Now