按照我用的方法很繁,而且使得[&Page]、[&Pages]这两个功能用不了,
现在我又看了一下Ehlib2.0的源代码,觉得可以这样试试:
修改过程PrintTo中的子过程:
procedure PrintOutInfo;
begin
PrintRichText(TRichEditStrings(BeforeGridText));
if PrintOffset >= DataPrintRec.Bottom - DataPrintRec.Top then
begin
VPrinter_NewPage;
PrintOffset := 0;
end;
InitPolyBookmark(PBm1);
while True do begin
PBm2 := CalcPrintRows(PBm1, DataPrintRec.Top + PrintOffset, DataPrintRec.Bottom);
PrintOffset := DrawRowsRange(PBm1,PBm2) + PenW;
if (PBm2.EOF = True)
then Break
else PrintOffset := 0;
PBm1 := PBm2;
end;
VPrinter_Canvas.BRUSH.Style := bsClear;
VPrinter_Canvas.Brush.Color := clWhite;
PrintRichText(TRichEditStrings(AfterGridText));
end;
为:
procedure PrintOutInfo;
var
richh : integer;
saveCalcInfoMode:boolean;
begin
//首先必须保证beforetext与aftertext两者高度不得超过DataPrintRec的高度,否则将陷入死循环;
saveCalcInfoMode:=CalcInfoMode;
CalcInfoMode := True;
PrintRichText(TRichEditStrings(AfterGridText));
richh:=PrintOffset;
PrintOffset:=0;
PrintRichText(TRichEditStrings(BeforeGridText));
CalcInfoMode := saveCalcInfoMode;
if PrintOffset + richh >= DataPrintRec.Bottom - DataPrintRec.Top { +Grid的最小高度 } then
此处加入发出错误信息代码
PrintOffset:=0;
InitPolyBookmark(PBm1);
while True do begin
PrintRichText(TRichEditStrings(BeforeGridText));
PBm2 := CalcPrintRows(PBm1, DataPrintRec.Top + PrintOffset, DataPrintRec.Bottom-richh - PenW);
PrintOffset := DrawRowsRange(PBm1,PBm2) + PenW;
PrintRichText(TRichEditStrings(AfterGridText));
if (PBm2.EOF = True)
then Break
else PrintOffset := 0;
PBm1 := PBm2;
end;
VPrinter_Canvas.BRUSH.Style := bsClear;
VPrinter_Canvas.Brush.Color := clWhite;
end;