Solved

Multiple printers / save settings / quickreport

Posted on 2002-04-29
4
2,059 Views
Last Modified: 2013-11-22
Hi there,

I am using some source code to configure printer settings within my application. Therefore I am using the Printers object (I added Printers into my uses clause).

When I want to print a report, the application is reading the specific printer settings from an INI-file and copying these settings into the printersettings of QuickReport:

With QuickRep1.PrinterSettings do
begin
  PrinterIndex := Printers.PrinterIndex;
  Copies       := Printer.Copies;
  Orientation  := Printers.Orientation;
end;

This part looks fine to me. I did not test it yet, but I think this will work because I was able to compile the application without any errors.

However, when I try to copy the settings for PaperSize and OutputBin the application will not compile anymore because of some errors:

With QuickRep1.PrinterSettings do
begin
  PaperSize := Printers.PaperSize;
  OutputBin := Printers.DefaultSource;
end;

I have split up this question in the following issues:

1. How can I copy the PaperSize and DefaultSource values (as stored in the object Printers) into the PrinterSettings of QuickReport?
2. Do I need to use the methods Create and ApplySettings?
3. Please provide me with a complete example in order to learn how to solve this (big) problem.

Thank you very much for your help !!!!!!!!!!

gr.,
RoosieDB
0
Comment
Question by:roosiedb
[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
4 Comments
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6982444
this is how to get/set printer settings. should get you started.


// Assert confguration details
procedure TForm1.PrinterConfig;
var
 Device, Driver, Port: array[0..80] of Char;
 DevMode: THandle;
 PDevMode: PDeviceMode;
begin
 Printer.GetPrinter(Device, Driver, Port, DevMode); // Get printer device name etc.
 Printer.SetPrinter(Device, Driver, Port, 0);  // force reload of DEVMODE
 Printer.GetPrinter(Device, Driver, Port, DevMode); // get DEVMODE
 if not (DevMode = 0) then
 begin
   PDevMode := GlobalLock(DevMode); // lock it to get pointer to DEVMODE record
   if not (PDevMode = nil) then
   try
     with PDevMode^ Do
     begin
       // example: change the paper size
       dmPapersize := DMPAPER_A4;
       dmFields := dmFields or DM_PAPERSIZE; // force driver to re-select size
       // set something else
       // ..
     end;
   finally
     GlobalUnlock(DevMode);
   end;
 end;
end;
0
 

Author Comment

by:roosiedb
ID: 6984397
Hi SteveWaite,

Your example is working for "normal" printing jobs, however, when I use QuickReport I will need to set its PrinterSettings there. Could you please help me further with this?

gr.,
RoosieDB
0
 
LVL 3

Accepted Solution

by:
SteveWaite earned 200 total points
ID: 6984917
I've not used quickreport. Have you checked the help?

It looks like you would need a bit of work to set some parameters, for example probably use a case statement to set the paper size:

TQRPaperSize = (Default, Letter, LetterSmall, Tabloid, Ledger, Legal,
                Statement, Executive, A3, A4, A4Small, A5, B4, B5, Folio,
                Quarto, qr10X14, qr11X17, Note, Env9, Env10, Env11, Env12,
                Env14, CSheet, DSheet, ESheet, Custom)
property PaperSize : TQRPaperSize

so you might do something like:
with PDevMode^ do
begin
  case dmPapersize of
    DMPAPER_A4: QuickRep1.Printers.PaperSize := A4;
etc.

Regards,
Steve

 
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9004385
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from SteveWaite

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

695 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