Solved

I need a non-interactive replacement for PrintDlg

Posted on 2009-04-02
5
933 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

830 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