Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need a non-interactive replacement for PrintDlg

Posted on 2009-04-02
5
Medium Priority
?
953 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

604 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