ReportBuilder 中ppMemo不支持中文换行的Bug 的修正

本文介绍如何解决ReportBuilder中ppMemo组件在换行时出现的乱码问题,通过修改源代码中的ppPlainText.pas文件实现,并提供详细的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ReportBuilder ppMemo在换行时会产生乱码。修改源代码可以搞定。


步骤如下
1。修改
rbRCL107.dpk中的ppPlainText.pas


 // ppPlainText.pas 

 procedure TppTextWrapper.WrapCharacters(const aLine: String; var aNextWord, aRemainingChars: String);
var
  lbFits: Boolean;
  liLineWidth: Integer;
  liIndex: Integer;
  lsCurrentLine: String;
  lsNextWord: String;
begin

  lsNextWord := aNextWord;
  lsCurrentLine := aLine;

  liIndex := 1;
  lbFits := True;
  aRemainingChars := '';

  while lbFits and (liIndex <= Length(lsNextWord)) do
    begin

      liLineWidth := CalcTextWidth(lsCurrentLine + lsNextWord[liIndex]);

      {there is room to print next word on current line}
      if (liLineWidth <= FWidthAvailable) then
        lsCurrentLine := lsCurrentLine + lsNextWord[liIndex]

      else
        begin
          lbFits := False;

          if (liIndex = 1) then
            begin

              if (aLine <> '') then
                begin
                  aNextWord := '';

                  aRemainingChars := lsNextWord;
                end

              else
                begin
                  aNextWord := lsNextWord[1];

                  aRemainingChars := Copy(lsNextWord, 2, Length(lsNextWord));
                end;

            end

          else
            begin
        ///修改--begin
              if StrByteType(Pchar(lsNextWord),liIndex)=mbLeadByte  then //如果换行的第一个字符是中文的   ////////{就。。。}
              begin
                aNextWord := Copy(lsNextWord, 1, liIndex - 2);
                aRemainingChars := Copy(lsNextWord, liIndex-1, Length(lsNextWord));
              end else
              begin
                aNextWord := Copy(lsNextWord, 1, liIndex - 1);
                aRemainingChars := Copy(lsNextWord, liIndex, Length(lsNextWord));
              end;
        ///修改--end;
            end;

        end;



      Inc(liIndex);

    end;

end;

2、重新编译rbRCL107.bpk
3、关闭delphi.
4、/Program Files/Borland/Delphi7/Projects/Bpl 中复制
rbRCL107.bpl 和rbRCL107.dcp到
   /WINDOWS/system32 覆盖原来的文件。
再次打开
delphi,试一试,呵呵,已经搞定了!


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值