Multiple printers / save settings / quickreport

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
roosiedbAsked:
Who is Participating?
 
SteveWaiteCommented:
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
 
SteveWaiteCommented:
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
 
roosiedbAuthor Commented:
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
 
pnh73Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.