-------------------------------------------------- Tech Tip: Windows Default Printer Settings ---------------------------------------------------
1. Default Printer Name
You can get the name of the computers default printer by accessing ReportBuilder's global printer list object - ppPrinters.
uses ppPrintr;
var lsPrinterName: String
begin
lsPrintername := ppPrinters.DefaultPrinterName;
end;
2. Default Printer Setup
Place the following code in the OnClick event-handler of a button on a form. When the button is pressed a message will be displayed showing the default printer name and paper size.
You can get the other document defaults via the TppPrinter.PrinterSetup properties.
Maybe i was't clear enough. I know lPrinter.PrinterSetup.BinName gives me the default BinName given by reportbuilder which always will be 'Default'. lPrinter.PrinterSetup.BinNames will give me the collection of available bins for that printer. Fi: 'Default','Tray 1',Tray 2','Tray 3'. The default bin for that printer is set in 'windows' to 'Tray 1'. Now, how do i get the default bin (aka 'Tray 1') for that printer?
Comments
--------------------------------------------------
Tech Tip: Windows Default Printer Settings
---------------------------------------------------
1. Default Printer Name
You can get the name of the computers default
printer by accessing ReportBuilder's global
printer list object - ppPrinters.
uses
ppPrintr;
var
lsPrinterName: String
begin
lsPrintername := ppPrinters.DefaultPrinterName;
end;
2. Default Printer Setup
Place the following code in the OnClick event-handler
of a button on a form. When the button is pressed
a message will be displayed showing the default
printer name and paper size.
You can get the other document defaults via
the TppPrinter.PrinterSetup properties.
uses
ppPrintr;
var
lPrinter: TppPrinter;
begin
lPrinter := TppPrinter.Create;
lPrinter.PrinterName := ppPrinters.DefaultPrinterName;
ShowMessage(ppPrinters.DefaultPrinterName + ': ' +
lPrinter.PrinterSetup.PaperName);
{assign default printer settings to a report}
myReport.PrinterSetup := lPrinter.PrinterSetup;
lPrinter.Free;
end;
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Maybe i was't clear enough. I know lPrinter.PrinterSetup.BinName gives me
the default BinName given by reportbuilder which always will be 'Default'.
lPrinter.PrinterSetup.BinNames will give me the collection of available bins
for that printer.
Fi: 'Default','Tray 1',Tray 2','Tray 3'. The default bin for that printer is
set in 'windows' to 'Tray 1'. Now, how do i get the default bin (aka 'Tray
1') for that printer?
TppCustomPrinterAccess(lPrinter).DefaultBin returns 0
lPrinter.DefaultBinName returns ''
Greetings,
Filip Moons
Thanks the clarification on what you are trying to do.
Here is an example I created.
uses
ppPrintr;
procedure TForm1.Button1Click(Sender: TObject);
var
lDevMode: THandle;
lPDevMode: PDeviceMode;
liDefaultBin: Integer;
liBinIndex: Integer;
lsBinName: string;
begin
{clear current dev mode}
ppPrinter.SetDevMode(0);
{get dev mode that reflects printer control panel}
ppPrinter.GetDevMode(lDevMode);
lPDevMode := GlobalLock(lDevMode);
// get bin value
liDefaultBin := lPDevMode^.dmDefaultSource;
// use bin value to get bin index
liBinIndex :=
ppPrinter.PrinterCapabilities.Bins.IndexOf(IntToStr(liDefaultBin));
// use bin index to get bin name
lsBinName := ppPrinter.PrinterCapabilities.BinNames[liBinIndex];
ShowMessage(lsBinName);
GlobalUnlock(lDevMode);
GlobalFree(lDevMode);
end;
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com