September 20th, 2004, 04:50 AM
Set Printer for application
Does anyone know how to write the code to set a particular printer as default, but only for the applications run-time life. i.e your normal default printer will be as usual when you exit the running application.
September 22nd, 2004, 01:39 PM
1. In the uses section, add Printers to the list. This will enable you to use a globally declared object called Printer.
2. In your code, add the following:
Hope this helps
procedure TForm1.FormCreate(Sender: TObject);
nInd : integer;
nInd := Printer.Printers.IndexOf('HP 500-XL');
if nInd >= 0 then
Printer.PrinterIndex := nInd;
// Now set the PaperSize property to any value (even an invalid one will do!). Without this, you may
// get access errors when you open the Print dialog box
// See http://community.borland.com/article/0,1410,15603,00.html for how to do this, if you get access errors.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo