I had 'Canvas does not allow drawing'
Hi,
I had a report that I was creating programmatically that had 2 subreports
with child reports in them and fields in each. When I ran it a I got to the
first field in the second child report it would report that the 'Canvas does
not allow drawing'. I tracked to the AutoSize:=true in the create of the
ppcustomlabel. When it does this assignment it goes and gets a handle for
the printer canvas and fails because it is returning a zero.
I had for my code to create the childreport:
ASubReport:=TppSubReport.Create(Self);
ASubReport.Band:=MainReport.DetailBand;
AChildReport:=TppChildReport.Ceate(Self);
AChildReport.Parent:=ASubReport;
ALabel:=TppLabel.Create(Self);
etc.
I found a tip that created the child report differently. It had:
ASubReport:=TppSubReport.Create(Self);
ASubReport.Band:=MainReport.DetailBand;
ASubReport:CreateReport(MainReport); //<<
AChildReport:=TppChildReport(ASubReport.Report); //<<
ALabel:=TppLabel.Create(Self);
etc.
This solved the problem. I'm not sure why. If you see this problem, try
looking for this.
Thanks,
Joseph Gordon
I had a report that I was creating programmatically that had 2 subreports
with child reports in them and fields in each. When I ran it a I got to the
first field in the second child report it would report that the 'Canvas does
not allow drawing'. I tracked to the AutoSize:=true in the create of the
ppcustomlabel. When it does this assignment it goes and gets a handle for
the printer canvas and fails because it is returning a zero.
I had for my code to create the childreport:
ASubReport:=TppSubReport.Create(Self);
ASubReport.Band:=MainReport.DetailBand;
AChildReport:=TppChildReport.Ceate(Self);
AChildReport.Parent:=ASubReport;
ALabel:=TppLabel.Create(Self);
etc.
I found a tip that created the child report differently. It had:
ASubReport:=TppSubReport.Create(Self);
ASubReport.Band:=MainReport.DetailBand;
ASubReport:CreateReport(MainReport); //<<
AChildReport:=TppChildReport(ASubReport.Report); //<<
ALabel:=TppLabel.Create(Self);
etc.
This solved the problem. I'm not sure why. If you see this problem, try
looking for this.
Thanks,
Joseph Gordon
This discussion has been closed.
Comments
http://www.digital-metaphors.com/tips/DynamicSubreportCreation.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com