Solved

Multiple printers / save settings / quickreport

Posted on 2002-04-29
4
1,971 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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