Solved

Printing a text file with a MFC application

Posted on 1998-09-10
3
532 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
[X]
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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
only14 challenge 19 84
no14 challenge 14 73
modThree challenge 4 112
child constructor and parent constructor, overriding and overloading 6 93
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

726 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