Link to home
Start Free TrialLog in
Avatar of roosiedb
roosiedb

asked on

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
Avatar of SteveWaite
SteveWaite

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;
Avatar of roosiedb

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of SteveWaite
SteveWaite

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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