Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you print to non-default printer

Posted on 1998-10-08
2
Medium Priority
?
231 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 100 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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 …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

916 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