Solved

How do you print to non-default printer

Posted on 1998-10-08
2
201 Views
Last Modified: 2010-04-30
I would like to print but do so using a non-default printer.  I don't want to bring up the common dialog box on this one.  I want the user to be able to pick from a list of printers, the list of which is filled by parsing through the printers collection and filling the cmbo box with the devicenames of those printers.  Typically, if you use the printer object, then that object only uses the default printer.  But I know there's a way to use the hdc to print to a non-default printer without making that non-default printer default.  The hdc method is what I think I want to do.  But I don't know how to use it.  How can I print using a non-default printer without making it default and by using the hdc methods.  Thanks!
0
Comment
Question by:ksm
2 Comments
 
LVL 2

Expert Comment

by:shchuka
ID: 1438807
hdc methods you are mentioning are API methods.  Once you've obtained the hdc of the printer (device context), you can print to that hdc using API calls, such as
DrawText(), Rectangle(), Ellipse(), etc.

Note that in this case you will need to do your own print job management, i.e. output spool information, paginate output, etc.

Start looking at the StartDoc() API and go from there.

-Aleks.
0
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1438808
Set the printer object to the desired printer (setting as default), then once the print is done, set back to the previous default printer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now