Solved

I need a non-interactive replacement for PrintDlg

Posted on 2009-04-02
5
928 Views
Last Modified: 2013-11-25
I am extending an existing program which uses some various Windows printing API calls. I select the printer with PrintDlg, start a document with StartDoc, Close it with EndDoc, control pages with StartPage and EndPage and do text and graphics with TextOut, Rectangle, MoveToEX, LineTo, etc.. The program runs on Windows 2000, Windows XP, and Windows 2003 Server.

My problem is that I need to extend the program to print to another printer in a way that is invisible to the user of the program. The modified program will print one copy of the output to the printer selected by PrintDlg, and another copy to another printer which is selected with no user input whatsoever. I need a non-interactive substitute for PrintDlg that will let me use the rest of my printing stuff unchanged.

(Note that I am actually writing in Ada, not C, but any answers I get should probably best be expressed in terms of plain C, as I can easily translate.
0
Comment
Question by:jdgressett
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 24061986
Well, your replacement fot that API is - 'PrintDlg()'. Or better, the PRINTDLG struct filled in by your first interactive call to that function. You'd use make a copy of that struct and then alter the respective members (hDevMode, hDevNames and hDC) to represent the other printer you want to send your output to.
0
 

Author Comment

by:jdgressett
ID: 24163045
I may have a solution using CreateDC. I will get get back after I test it.
0
 

Accepted Solution

by:
jdgressett earned 0 total points
ID: 24280269
CreateDC does indeed work for what I need to do. The core of the thing is in the attached snippet.
type Pointer_To_DEVMODE is access all DEVMODE;

    type Pointer_To_char is access constant Interfaces.C.char;

    

    function CreateDC (

      lpszDriver: Pointer_To_char;

      lpszDevice: Pointer_To_char;

      lpszOutput: Pointer_To_char;

      lpInitData: Pointer_To_DEVMODE

    )

      return GWindows.Types.Handle;

    pragma Import(StdCall, CreateDC, "CreateDCA");

Open in new window

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

867 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

22 Experts available now in Live!

Get 1:1 Help Now