question about aligns the summaryband to the bottom.
I download the deom which aligns the summaryband to the bottom.
http://www.digital-metaphors.com/tips/AlignSummaryToBottom.zip
Because I use ppDesigner, so I use the follow code to set the
AlignSummaryToButton code when I load the report:
procedure TfrmMain.ppDesigner1CustomOpenDoc(Sender: TObject);
begin
try
ppDesigner1.Report.Template.Load;
if not ppReport1.SaveAsTemplate then
ppReport1.SaveAsTemplate := true;
IniReportSummary(ppReport1);
except on E: Exception do
ErrorMsg('Load Error: ' + E.Message, 'Error!');
end;
end;
procedure TfrmMain.DrawCommandCreate(Sender, aDrawCommand: TObject);
begin
if Assigned(FDrawCommandList) then
FDrawCommandList.Add(aDrawCommand);
end;
procedure TfrmMain.SummaryBand1AfterPrint(Sender: TObject);
var
liSummaryTop: Integer;
liNewSummaryTop: Integer;
liIndex: Integer;
lDrawCommand: TppDrawCommand;
begin
if Assigned(ppReport1.Summary) and Assigned(FDrawCommandList) then
begin
liSummaryTop := ppReport1.Summary.PrintPosRect.Top;
liNewSummaryTop := ppReport1.Engine.PageBottom -
ppReport1.Summary.SpaceUsed;
for liIndex := 0 to FDrawCommandList.Count - 1 do
begin
lDrawCommand := TppDrawCommand(FDrawCommandList[liIndex]);
lDrawCommand.Top := (lDrawCommand.Top - liSummaryTop) +
liNewSummaryTop;
end;
end;
end;
procedure TfrmMain.IniReportSummary(aReport: TppReport);
var
i: integer;
begin
if not Assigned(aReport.Summary) then
exit;
for i := 0 to aReport.Summary.ObjectCount - 1 do
aReport.Summary.Objects[i].OnDrawCommandCreate := DrawCommandCreate;
aReport.OnStartPage := ReportStartPage;
aReport.SummaryBand.AfterPrint := SummaryBand1AfterPrint;
end;
procedure TfrmMain.ReportStartPage(Sender: TObject);
begin
FDrawCommandList.Clear;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
FDrawCommandList.Free;
end;
It works fine if I load the report from the designer and preview the report
in the preview tab. But if I change the report: ie: add some DBText or
delete some ppLabel, and preview the report again, the summary band will go
back to the bottom of the detail band. And I must reload the report again
and preview the report. It looks the ReportStartPage just trigger once when
the designer preview the report.
How can I fix the problem?
Many thanks
Tao
http://www.digital-metaphors.com/tips/AlignSummaryToBottom.zip
Because I use ppDesigner, so I use the follow code to set the
AlignSummaryToButton code when I load the report:
procedure TfrmMain.ppDesigner1CustomOpenDoc(Sender: TObject);
begin
try
ppDesigner1.Report.Template.Load;
if not ppReport1.SaveAsTemplate then
ppReport1.SaveAsTemplate := true;
IniReportSummary(ppReport1);
except on E: Exception do
ErrorMsg('Load Error: ' + E.Message, 'Error!');
end;
end;
procedure TfrmMain.DrawCommandCreate(Sender, aDrawCommand: TObject);
begin
if Assigned(FDrawCommandList) then
FDrawCommandList.Add(aDrawCommand);
end;
procedure TfrmMain.SummaryBand1AfterPrint(Sender: TObject);
var
liSummaryTop: Integer;
liNewSummaryTop: Integer;
liIndex: Integer;
lDrawCommand: TppDrawCommand;
begin
if Assigned(ppReport1.Summary) and Assigned(FDrawCommandList) then
begin
liSummaryTop := ppReport1.Summary.PrintPosRect.Top;
liNewSummaryTop := ppReport1.Engine.PageBottom -
ppReport1.Summary.SpaceUsed;
for liIndex := 0 to FDrawCommandList.Count - 1 do
begin
lDrawCommand := TppDrawCommand(FDrawCommandList[liIndex]);
lDrawCommand.Top := (lDrawCommand.Top - liSummaryTop) +
liNewSummaryTop;
end;
end;
end;
procedure TfrmMain.IniReportSummary(aReport: TppReport);
var
i: integer;
begin
if not Assigned(aReport.Summary) then
exit;
for i := 0 to aReport.Summary.ObjectCount - 1 do
aReport.Summary.Objects[i].OnDrawCommandCreate := DrawCommandCreate;
aReport.OnStartPage := ReportStartPage;
aReport.SummaryBand.AfterPrint := SummaryBand1AfterPrint;
end;
procedure TfrmMain.ReportStartPage(Sender: TObject);
begin
FDrawCommandList.Clear;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
FDrawCommandList.Free;
end;
It works fine if I load the report from the designer and preview the report
in the preview tab. But if I change the report: ie: add some DBText or
delete some ppLabel, and preview the report again, the summary band will go
back to the bottom of the detail band. And I must reload the report again
and preview the report. It looks the ReportStartPage just trigger once when
the designer preview the report.
How can I fix the problem?
Many thanks
Tao
This discussion has been closed.
Comments
triggered more than once, and causing the event handlers to be lost. I
suspect your code in IniReportSummary
is causing the problem?
The OnStartPage should fire everytime a new page is about to print. I'd
also drop a breakpoint in there to make sure that the event handler is
getting called for every page in the report. If it only gets called once,
then check the if statement condition, which assigns the OnStartPage event
handler.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com