How to copy setting in TPrinter to Report?
Hi,
I'm trying to copy settings from application Printer object to
ppReport.PrinterSetup but I can't get some parameters like colour
settings, copies, orientation, etc..
This is my code:
// *******************************************************************
lPrinter:=TppPrinter.Create;
lPrinter.PrinterSetup.PrinterName:=Printer.Printers[Printer.PrinterIndex];
Printer.printerindex:=printer.printerindex;
Printer.GetPrinter(aDevice, aDriver, aPort, aDevMode);
if aDevMode=0 then lPrinter.SetDevMode(aDevMode);
ppReportCX.PrinterSetup:=lPrinter.PrinterSetup;
ppReportCX.PrinterSetup.BinName:=lsBinName;
ppReportCX.PrinterSetup.DocumentName:=FNomListado;
// *******************************************************************
this changes PrinterSetup to application Printer object but sets tray,
colour options, etc.. from application Printer object.
Any suggestion?
I'm trying to copy settings from application Printer object to
ppReport.PrinterSetup but I can't get some parameters like colour
settings, copies, orientation, etc..
This is my code:
// *******************************************************************
lPrinter:=TppPrinter.Create;
lPrinter.PrinterSetup.PrinterName:=Printer.Printers[Printer.PrinterIndex];
Printer.printerindex:=printer.printerindex;
Printer.GetPrinter(aDevice, aDriver, aPort, aDevMode);
if aDevMode=0 then lPrinter.SetDevMode(aDevMode);
ppReportCX.PrinterSetup:=lPrinter.PrinterSetup;
ppReportCX.PrinterSetup.BinName:=lsBinName;
ppReportCX.PrinterSetup.DocumentName:=FNomListado;
// *******************************************************************
this changes PrinterSetup to application Printer object but sets tray,
colour options, etc.. from application Printer object.
Any suggestion?
This discussion has been closed.
Comments
The TPrinter object does not contain the same information as the TppPrinter
object used in ReportBuilder (it is much more advanced). You will need to
use the Windows API to obtain the values you are after. Take a look at the
DEVMODE structure and the TppPrinter class located in the ppPrintr.pas file
for more information.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Hi Nico, thanks for your help.
I took a look at ppPrintr.pas, but I can't figure out how can I solve my
problem.
I can specify certain parameters, such as tray, with the following code:
lPrinter := TppPrinter.Create;
lPrinter.PrinterSetup.PrinterName:=Printer.Printers[Printer.PrinterIndex];
// Get Printer object settings
Printer.printerindex:=printer.printerindex;
Printer.GetPrinter(aDevice, aDriver, aPort, aDevMode);
miDevMode:=globallock(aDevMode);
// Set lPrinter with same settings;
if aDevMode=0 then lPrinter.SetDevMode(aDevMode);
// Get selected tray name
liBinIndex:=lPrinter.PrinterCapabilities.Bins.IndexOf(inttostr(midevmode.dmDefaultSource));
lsBinName:=lPrinter.PrinterCapabilities.BinNames[liBinIndex];
// This line sets printer Report to point application Printer object
ppReportCX.PrinterSetup:=lPrinter.PrinterSetup;
// This line selects tray
ppReportCX.PrinterSetup.BinName:=lsBinName;
ppReportCX.PrinterSetup.DocumentName:=FNomListado;
GlobalUnlock(aDevMode);
... but what about the other settings, like colour, copies, rotation, etc..?
I'm missing something?
Can I adopt another strategy? Maybe a custom print dialog?
I would greatly appreciate if you can point me to code sample
Thanks a lot.
Nico Cizik (Digital Metaphors) escribió: