Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multiple printers / save settings / quickreport

Posted on 2002-04-29
4
Medium Priority
?
2,185 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 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

916 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