Üdv!
A lazreportot ki szeretném nyomtatni, akkor printdialog komponenssel engedem a usernek, hogy válasszon nyomtatót.
A Lazarus example szerint:
procedure TForm1.printBtnClick(Sender: TObject);
var
FromPage, ToPage, NumberCopies: Integer;
ind: Integer;
Collap: Boolean;
begin
// printing
// Load report definition from application directory
// AppDirectory:=ExtractFilePath(ParamStr(0));
frReport1.LoadFromFile('lazrep1.lrf');
// Need to keep track of which printer was originally selected to check for user changes
// ind:= Printer.PrinterIndex;
// Prepare the report and just stop if we hit an error as continuing makes no sense
if not frReport1.PrepareReport then Exit;
// Set up dialog with some sensible defaults which user can change
with PrintDialog1 do
begin
Options:=[poPageNums ]; // allows selecting pages/page numbers
Copies:=1;
Collate:=true; // ordened copies
FromPage:=1; // start page
ToPage:=frReport1.EMFPages.Count; // last page
MaxPage:=frReport1.EMFPages.Count; // maximum allowed number of pages
if Execute then // show dialog; if succesful, process user feedback
begin
if (Printer.PrinterIndex <> ind ) // verify if selected printer has changed
or frReport1.CanRebuild // ... only makes sense if we can reformat the report
or frReport1.ChangePrinter(ind, Printer.PrinterIndex) //... then change printer
then
frReport1.PrepareReport //... and reformat for new printer
else
exit; // we couldn't honour the printer change
if PrintDialog1.PrintRange = prPageNums then // user made page range selection
begin
FromPage:=PrintDialog1.FromPage; // first page
ToPage:=PrintDialog1.ToPage; // last page
end;
NumberCopies:=PrintDialog1.Copies; // number of copies
// Print the report using the supplied pages & copies
frReport1.PrintPreparedReport(inttostr(FromPage)+'-'+inttostr(ToPage), NumberCopies);
end;
end;
end;
Ez oké is, de hiába adja meg kódban, hogy "PrintDialog1.Copies:=1" a printdialógban lehet állítani a példányszámot.
Lehet ezt valahogy rögzíteni? Hogy a printdialógban ne tudjon a user többet nyomtatni, mint amennyit megadok?