?
Solved

I need a non-interactive replacement for PrintDlg

Posted on 2009-04-02
5
Medium Priority
?
947 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Make the most of your online learning experience.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Starting up a Project
Suggested Courses

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