Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

select printer with mfc using visual c++ 1.52c

Posted on 1998-02-18
6
Medium Priority
?
523 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 600 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
Independent Software Vendors: 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

Industry Leaders: 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!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

927 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