Solved

select printer with mfc using visual c++ 1.52c

Posted on 1998-02-18
6
473 Views
Last Modified: 2011-10-03
I am writting a 16 bit windows program using vc++ 1.52c & mfc. How can I have my program select different printers without having the user select from the print dialog box?
0
Comment
Question by:mikeu
6 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1182470
Basically, you need to use CreateDC() to create the printer's DC so that you can use it. You can use EnumPrinters() and EnumPrinterDrivers() to find out which printers are attached.

Once you have the DC, then you can use the regular APIs:

  StartDoc();
  StartPage();
  EndPage();
  EndDoc();
 
to print it. Or, you can copy most of the code from MFC to use your doc/view's printing routines. Note that some of routines for MFC's CWinApp should have been made virtual so that you can override them instead of copying and pasting code.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1182471
Are you trying to set the default printer from your application?
0
 

Author Comment

by:mikeu
ID: 1182472
Yes I was really trying to change the default printer
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mikeu
ID: 1182473
I don't think EnumPrinters is available from VC++ 1.52c.
This programs nedds to be 16 bit.
0
 

Expert Comment

by:ngoa
ID: 1182474
Can you control the print jobs after you CreateDC()?  I mean can you hold the print jobs then select the particular job and let it prints first?
0
 

Author Comment

by:mikeu
ID: 1182475
I was able to get it to work by changing the ini file as follows
// update the ini file
WritePrivateProfileString("windows","device","Panasonic KX-P1123,PANSON24,LPT1:","WIN.INI");
SendMessage( WM_WININICHANGE, 0, 0L);      
I just change the ProfileString for the printer I need at that time.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

685 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