Kambiz,
i was not aware of such considerations, you are certainly right.
After digging deeper, i think i am on the right track now...
Although you do not like to speak about the demos, it was my first reference of course. Sorry for that!
There you have a TRect called PageBoundsAfterMargin which is supposed to be the papersize minus the margins from the setupdialog.
After changing the orientation, the PageBoundsAfterMargin is not correct (still has the portrait-values), therefore it has to be rectified. This is done via GetPageSetupParameters. Before you can call GetPageSetupParameters you have to change the settings of the PageSetupDialog. This is done via SetPageSetupParameters - which unintendedly swaps the PageWidth and PageHeight back to portrait-values instead of setting them to PaperHeight and PaperWidth which are already set correctly.
Meaning:
- Code: Select all
PrintPreview.Orientation := poLandscape;
PrintPreview.SetPageSetupParameters(PageSetupDialog);
PageBoundsAfterMargin := PrintPreview.GetPageSetupParameters(PageSetupDialog);
PrintPreview.BeginDoc;
I hope i explained it understandably.
Anyway, after seeing what's going on, i have programmed my solution - without changing your code
- Code: Select all
PrintPreview.Clear;
PrintPreview.Printer.Orientation := poLandscape;
PrintPreview.Orientation := poLandscape;
PageSetupDialog.PageWidth := PrintPreview.ConvertX(PrintPreview.PaperWidth , PrintPreview.Units, OutUnit);
PageSetupDialog.PageHeight := PrintPreview.ConvertY(PrintPreview.PaperHeight, PrintPreview.Units, OutUnit);
PageBoundsAfterMargin := PrintPreview.GetPageSetupParameters(PageSetupDialog);
PrintPreview.BeginDoc;
Thanks and best wishes, WP