Solved

I need a non-interactive replacement for PrintDlg

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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

19 Experts available now in Live!

Get 1:1 Help Now