We help IT Professionals succeed at work.

Printing in Windows 95

Mark Ebden
Mark Ebden asked
Medium Priority
Last Modified: 2010-04-01
This goes hand-in-hand with my previous question, Q.10075158.

Please provide specific lines of code in Visual C++ for the following task.  I will only accept specific lines of code.

Print a char variable, say "firstname", in a particular place on the page, say 1.2 inches from the top and 3 inches from the left of an 8.5 x 11 inch paper.  The paper is run through a LaserJet 5L printer running from a Windows 95 PC.  Don't hesitate to ask if you need more details.

Thank you,

Watch Question

Mark do you want to stick with the "writing to the printer file" approach.  (i.e. the wrong way).
Or are you looking to change to the Windows way?

A Console Application or a GUI Application?


Am I right in thinking that the "writing to the printer file" way is easier?  If so, then let's make a quick fix.  However if the correct, Windows, way is not too much of a transformation, let's go with that.  It's your call -- thanks!

To answer chensu's question, I think it is a GUI application, but I'm not sure what the difference is.  I use windows -- doesn't that make it GUI automatically?

Actually, it has to be your call.  Do you have existing code that used to write directly to the printer?.  If so it may be easier to stay on that same approach.

However, if you are not working with existing code, or if you know you have to make the change eventually, then I would follow the windows approach.



Yes, I have existing code for Windows NT, available for perusal in Q.10075158, my previous question.  If the surgery is minor, please operate on that.

If you want to go the "writing directly to the printer approach" you code will not be very flexible.  It will have to work with a specific type of printer (or printers if you get little fancy).  You can probalby do ordinarly looking at specific locations on the page, but more complex things like different fonts and graphics are going to get very hard.  Everything you do will require knowing printer control codes.  You will need to look up the code for the specific model printer you are using.  

If you go with the windows approach, your code will work with any printer attached to the computer. Thus you don't have to worry about supporting a specific model printer.  You can do text in all sorts of fonts and styles and positioned precisely.  You can do graphics just as easily as you can do text.  You don't have to know any printer control codes.  Windows takes care of it for you.  In the unlikely case that you try to use a feature that is not available for a printer, windows will do its best to simulate that feature or will just ignore what you are doing.

Can you call CommonDialog a PRINTDLG to get Printer DC?

Mark that code is so short you can easily change it to use the windows method.  The question is do you have thousands of lines of code that would have to be converted.  If that was it, no debate go to windows.  

If you can (and want to) send me a copy of the program I might be able to give you a better idea of which way to go.  My e-mail address is nietod@theshop.net.  It is worth spending some time on making the right decision here rather than proceeding in the wrond direction.


I don't think my last comment was added properly.  I restarted Internet Explorer and I'll retype it.

I like the idea of being able to print from any printer.  My printing involves only text -- placing about a dozen pieces of information (first name, birth date, etc.) in particular boxes of a form fed through the printer.  There are not thousands of lines to change, but the Windows way seems better -- the printer versatility you mentioned is desirable.

Oh I must go now but I can send the code later in the day.  Many thanks in advance for looking it over.

Settled then.  Windows it is.  Ignore the code I posted to the other question then.  

Now where to begin.  First of all, I think someone already asked this, but how do you want to select the printer to print to.  The typical windows way is to let the user chose the printer etc ind a dialog (built-in to windows).  You obviously weren't doing it that way before.  Do you want to now?  If not we can still print to a specific printer, but I would think that the dialog is a better way to go.
Unlock this solution and get a sample of our free trial.
(No credit card required)

By the way, I answered this to prevent others from answering.  I think you already paid for an answer in the other question.  If you like, when we are done, you can reject my answer and after 21 days the question will be deleted and you will get back your points.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.