coposite report pagesetup problem
if i try to change margins with pagesetup dialog using composite report
it rebuilds a page but it doesn't change anything
if i try without composite report , setupdialog change margins.
does anyone know how to resolve the problem?
thanks in advance
it rebuilds a page but it doesn't change anything
if i try without composite report , setupdialog change margins.
does anyone know how to resolve the problem?
thanks in advance
Comments
procedure TfrPreviewForm.PageSetupBtnClick(Sender: TObject);
fr version 2.5 FR_View.pas unit
i have modified the source code and now it works
this is the code:
procedure TfrPreviewForm.PageSetupBtnClick(Sender: TObject);
var
psd: TPageSetupDlg;
pg: PfrPageInfo;
pg1: TfrPage;
i: Integer;
s: Integer;
rep: TfrReport;
RepItem: TfrReport;
Composite: TfrCompositeReport;
procedure SetPrinter(DeviceMode, DeviceNames: THandle);
var
DevNames: PDevNames;
begin
DevNames := PDevNames(GlobalLock(DeviceNames));
try
with DevNames^ do
Printer.SetPrinter(PChar(DevNames) + wDeviceOffset,
PChar(DevNames) + wDriverOffset,
PChar(DevNames) + wOutputOffset, DeviceMode);
finally
GlobalUnlock(DeviceNames);
GlobalFree(DeviceNames);
end;
end;
begin
if EMFPages = nil then Exit;
psd.lStructSize := SizeOf(TPageSetupDlg);
psd.hwndOwner := ScrollBox1.Handle;
psd.hDevMode := prn.DevMode;
psd.hDevNames := 0;
psd.Flags := PSD_DEFAULTMINMARGINS or PSD_MARGINS or PSD_INHUNDREDTHSOFMILLIMETERS;
pg := TfrEMFPages(EMFPages)[0];
psd.rtMargin.Left := pg^.pgMargins.Left * 500 div 18;
psd.rtMargin.Top := pg^.pgMargins.Top * 500 div 18;
psd.rtMargin.Right := pg^.pgMargins.Right * 500 div 18;
psd.rtMargin.Bottom := pg^.pgMargins.Bottom * 500 div 18;
if PageSetupDlg(psd) then
begin
rep := TfrReport(Doc);
if rep.ClassNameIs('TfrCompositeReport') then
begin
Composite := (rep as TfrCompositeReport);
for s := 0 to Composite.Reports.Count -1 do
begin
RepItem := TfrReport(Composite.Reports);
for i := 0 to RepItem.Pages.Count - 1 do
begin
pg1 := RepItem.Pages;
if pg1.PageType = ptReport then
begin
pg1.pgMargins.Left := psd.rtMargin.Left * 18 div 500;
pg1.pgMargins.Top := psd.rtMargin.Top * 18 div 500;
pg1.pgMargins.Right := psd.rtMargin.Right * 18 div 500;
pg1.pgMargins.Bottom := psd.rtMargin.Bottom * 18 div 500;
pg1.ChangePaper(Prn.PaperSize, 0, 0, Prn.Bin, Prn.Orientation);
end;
end;
end;
end
else
begin
for i := 0 to TfrReport(Doc).Pages.Count - 1 do
begin
pg1 := TfrReport(Doc).Pages;
if pg1.PageType = ptReport then
begin
pg1.pgMargins.Left := psd.rtMargin.Left * 18 div 500;
pg1.pgMargins.Top := psd.rtMargin.Top * 18 div 500;
pg1.pgMargins.Right := psd.rtMargin.Right * 18 div 500;
pg1.pgMargins.Bottom := psd.rtMargin.Bottom * 18 div 500;
pg1.ChangePaper(Prn.PaperSize, 0, 0, Prn.Bin, Prn.Orientation);
end;
end;
end;
SetPrinter(psd.hDevMode, psd.hDevNames);
Prn.Update;
TfrReport(Doc).PrepareReport;
TfrEMFPages(EMFPages).Free;
EMFPages := nil;
Connect(Doc);
RedrawAll(True);
end;
end;