Solved

How do you print to non-default printer

Posted on 1998-10-08
2
196 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 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

10 Experts available now in Live!

Get 1:1 Help Now