本人在使用“中国式报表(ereport)"控件的时候发现一个BUG,就是当要打印的记录分为几页的时候,它的表格下部会不受底部页边距的控制,一直打到那一页的最下面,当记录少得只有两三页时,这个现象还不是很明显,如果有7、8页的话就会打到页的最下面,甚至于还和下一页的记录连不上,比如从第200条直接跳到203条!!!这真是个怪问题,哪位大侠也遇见过,能否解决?请指教!
小弟叩谢了!!!

解决方案 »

  1.   

    给 ReportCell加上一个属性  WordBreak  是否自动折行
    TReportCell = class(TWinControl)
    private
      ......
      fWordBreak: Boolean;
      fAutoWidth: Boolean;
      Procedure SetAutoWidth(Const Value: Boolean);
      Procedure SetWordBreak(Const Value: Boolean);
      Procedure AdjustBounds;
    published
          Property WordBreak: Boolean Read fWordBreak Write SetWordBreak;
        Property AutoWidth: Boolean Read fAutoWidth Write SetAutoWidth;
      
      end;................
    implementation...............//修改下列过程
    Procedure TReportCell.CalcMinCellHeight;
    ..................
    //找到 下面代码段
         Case FHorzAlign Of
          0:
            Format := Format Or DT_LEFT;
          1:
            Format := Format Or DT_CENTER;
          2:
            Format := Format Or DT_RIGHT;
        Else
          Format := Format Or DT_LEFT;
        End;
       
      //在Case语句前面加上
        If fWordBreak Then
          Format := DT_EDITCONTROL Or DT_WORDBREAK
        Else
          Format := DT_EditControl;
    寻找下面过程
    Procedure TReportCell.PaintCell(hPaintDC: HDC; bPrint: Boolean);
    ...............
    ...............
    寻找下面代码段:
      SelectObject(hPaintDC, hPrevPen);
      DeleteObject(hTempPen);  // 绘制文字
      If Length(FCellText) > 0 Then
      Begin
        Windows.SetTextColor(hPaintDC, FTextColor);    //在此处添加      Format := DT_EditControl;
        Case FHorzAlign Of
          TEXT_ALIGN_LEFT:
            Format := Format Or DT_LEFT;
          TEXT_ALIGN_CENTER:
            Format := Format Or DT_CENTER;
          TEXT_ALIGN_RIGHT:
            Format := Format Or DT_RIGHT;
        Else
          Format := Format Or DT_LEFT;
        End;
    在上面注明的地方添加
        If fWordBreak Then
          Format := DT_EDITCONTROL Or DT_WORDBREAK
        Else
    过程 Constructor TReportCell.Create;
     里最后添加上
      fAutoWidth := False; //自动展宽特性
      fWordBreak := True; //自动折行特性
    添加3个过程
    //调整边界
    Procedure TReportCell.AdjustBounds;
    Var
      DC: HDC;
      SaveFont: HFont;
      TextSize: TSize;
      HF: THandle;
    Begin
      If (FAutoWidth) And (CellText <> '') Then
      Begin
        DC := GetDC(0);
        HF := CreateFontInDirect(FLogFont);
        SaveFont := SelectObject(DC, HF);
        GetTextExtentPoint32(DC, PChar(CellText), Length(CellText), TextSize);
        SelectObject(DC, SaveFont);
        ReleaseDC(0, DC);
        fCellWidth := TextSize.Cx + 12;
      End;
    End;//自动单元格宽度
    Procedure TReportCell.SetAutoWidth(Const Value: Boolean);
    Begin
      fAutoWidth := Value;
      If fAutoWidth then
         fWordBreak := false;
      AdjustBounds;
    End;
    //自动折行
    Procedure TReportCell.SetWordBreak(Const Value: Boolean);
    Begin
      fWordBreak := Value;
      If fWordBreak Then
        fAutoWidth := False;
    End;