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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy HuiEngineerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.