Change printer settings by code
I need to use the standard print dialog of Delphi instead the one included in FastReport to choose and setup the printer from the code but the printer settings (like color, bin, copies number) are not applied.
I'm using this code:
Using the following procedure (after the line "if not PrintDialog.Execute then Exit;") I can see that the setup is correctly applied to the Printer:
What is wrong ?
P.S. I'm using the version shipped with RAD Studio XE2
I'm using this code:
var
AIndex : Integer;
begin
frxReport.LoadFromFile(DllGlobalData.RootPath + SVAL__REPORT_FILE_NAME);
..........
..........
if not PrintDialog.Execute then Exit;
frxReport.PrepareReport(True);
frxreport.PrintOptions.ShowDialog := False;
AIndex := frxPrinters.IndexOf(Printer.Printers[Printer.PrinterIndex]);
if AIndex <> -1 then
begin
frxPrinters.PrinterIndex := AIndex;
frxreport.PrintOptions.Printer := frxPrinters[AIndex].Name;
frxreport.SelectPrinter;
frxReport.Print;
end;
end;
Using the following procedure (after the line "if not PrintDialog.Execute then Exit;") I can see that the setup is correctly applied to the Printer:
procedure CheckSettings;
var
hDevMode: THandle;
Device, Driver, Port: array[0..1024] of Char;
DeviceMode: PDevMode;
begin
Printer.GetPrinter(Device, Driver, Port, hDevMode);
if hDevMode <> 0 then
begin
DeviceMode := GlobalLock(hDevMode);
case DeviceMode^.dmColor of
DMCOLOR_COLOR: Label1.Caption := 'Color';
DMCOLOR_MONOCHROME: Label1.Caption := 'Monochrome';
else
Label1.Caption := 'Unknown';
end;
GlobalUnlock(hDevMode);
end;
end;
What is wrong ?
P.S. I'm using the version shipped with RAD Studio XE2
Comments
All works right now !
Thank you very much again.