Solved

select printer with mfc using visual c++ 1.52c

Posted on 1998-02-18
6
490 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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 a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

630 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