I have an application I'm working on in Delphi 5 (Win 2k) and I want to create a report which I can fax to various recipients. Creating the report is easy (I'm using Quick Reports), but I want to change the default printer driver and force the system to use a specific one (which is a fax driver), which will not be the Windows default printer. It should however, be set up the same on each PC so I will initially want to aim for that (and handle errors later). The problem is forcing it to use a specific printer driver. There aren't any obvious options in Quick Reports, so I can't set it as easily as I wanted. The one I want to use is linked to our Castell Fax Server so I can get that to generate the fax from the print job. Any ideas would be welcome. Thanks
![]() |
0 |
![]() |
"Ryan" <ryanofford@hotmail.com> wrote in message news:7802b79d.0312170825.540c784@posting.google.com... > I have an application I'm working on in Delphi 5 (Win 2k) and I want > to create a report which I can fax to various recipients. Creating the > report is easy (I'm using Quick Reports), but I want to change the > default printer driver and force the system to use a specific one > (which is a fax driver), which will not be the Windows default > printer. It should however, be set up the same on each PC so I will > initially want to aim for that (and handle errors later). > > The problem is forcing it to use a specific printer driver. There > aren't any obvious options in Quick Reports, so I can't set it as > easily as I wanted. > > The one I want to use is linked to our Castell Fax Server so I can get > that to generate the fax from the print job. > > Any ideas would be welcome. > > Thanks Check Help - Tprinter.setPrinter Tom
![]() |
0 |
![]() |
Managed to find the code I needed on QUSoft.com and it works perfectly. So have adapted this to find the current printer, swap to the one I want, and then swap back to the original one afterwards. Posting here in case it's of help to anyone else looking for this solution at some point later. Setting the Default Printer from code ===================================== If you need to use a different printer than the default you may have to change the default printer programmatically, run your report and then change it back. Here is some sample code to do this: procedure SetDefaultPrinter(PrinterName: String); var I: Integer; Device : PChar; Driver : Pchar; Port : Pchar; HdeviceMode: Thandle; aPrinter : TPrinter; begin Printer.PrinterIndex := -1; getmem( device, 255); getmem( Driver, 255); getmem( Port, 255); aPrinter := TPrinter.create; for I := 0 to Printer.printers.Count-1 do begin if Printer.printers[i] = PrinterName then begin aprinter.printerindex := i; aPrinter.getprinter( device, driver, port, HdeviceMode); StrCat(Device, ','); StrCat(Device, Driver ); StrCat(Device, Port ); WriteProfileString('windows', 'device', Device ); StrCopy( Device, 'windows' ); SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, Longint(@Device)); end; end; freemem( device, 255); freemem( Driver, 255); freemem( Port, 255); aPrinter.free; end;
![]() |
0 |
![]() |
"Ryan" <ryanofford@hotmail.com> wrote in message news:7802b79d.0312180515.642f8969@posting.google.com... > Managed to find the code I needed on QUSoft.com and it works > perfectly. So have adapted this to find the current printer, swap to > the one I want, and then swap back to the original one afterwards. You should also be able to use Printer.PrinterIndex := Printer.Printers.IndexOf (PrinterName);
![]() |
0 |
![]() |