select printer with mfc using visual c++ 1.52c

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?
mikeuAsked:
Who is Participating?
 
Tommy HuiConnect With a Mentor EngineerCommented:
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
 
jhanceCommented:
Are you trying to set the default printer from your application?
0
 
mikeuAuthor Commented:
Yes I was really trying to change the default printer
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mikeuAuthor Commented:
I don't think EnumPrinters is available from VC++ 1.52c.
This programs nedds to be 16 bit.
0
 
ngoaCommented:
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
 
mikeuAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.