Mega Code Archive

 
Categories / Delphi / Examples
 

Setting the maxpage property of the printdialog component

Question: When I set the MaxPage property of the PrintDialog component, the VCL always adds one to the number of pages shown in the dialog, and after execution, the Max page property does not change. Is this a bug? Answer: The VCL simply wraps the Windows common print dialog. You should fill in all the fields before executing the dialog, and after execution. Check the PrintDialog's FromPage and ToPage properties for the pages to print. Example: procedure TForm1.Button1Click(Sender: TObject); begin PrintDialog1.Options := [poPageNums]; PrintDialog1.PrintRange := prPageNums; PrintDialog1.MinPage := 1; PrintDialog1.MaxPage := 5; PrintDialog1.FromPage := 1; PrintDialog1.ToPage := 5; if PrintDialog1.Execute then begin ShowMessage(IntToStr(PrintDialog1.FromPage)); SdhowMessage(IntToStr(PrintDialog1.ToPage)); end; end;