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

本文介绍如何解决ReportBuilder中ppMemo组件在换行时出现的乱码问题,通过修改源代码中的ppPlainText.pas文件实现,并提供详细的步骤。
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,试一试,呵呵,已经搞定了!


20190427 功能:[修正版]修改ReportBuilder支持QRCode二维码 注: 1、DelphiZXIngQRCode.pas 为用到的二维码生成源码,来源https://github.com/foxitsoftware/DelphiZXingQRCode,版权由原作者所有 2、rbRCL106.bpl 为已经重新编译好的含可以生成QRCode二维码的bpl文件,也是目标文件 3、old文件夹里是旧源码备份 4、new文件夹里的pas文件为修改后的源码文件 实现步骤: 1、 需要修改RB源码文件,new文件夹里的pas文件为已经修改好的了,只要放到rb的source目录下替换掉旧文件则可: ppBarCode2DDrawCmd.pas ppSt2DBarC.pas ppTypes.pas 2、把DelphiZXIngQRCode.pas文件同时拷贝到rb的source目录下 3、使用delphi打开rb的source目录下的rbRCL106.dpk项目,然后编译,输出的rbRCL106.bpl文件为目标文件(一般输出到这个目录下Delphi6\Projects\Bpl) 4、把rbRCL106.bpl文件替换掉原安装rb时的同名文件则可,一般该文件放在windows\system32下,如果是发布给客户用的话,直接把该文件给客户则可 附: a、支持中文,具体可以在TppStMaxiCodeBarcode.GenerateBarcodeBitmap_QRCode这里设置QRCode.Encoding来支持具体的字符集。 QQ扫码支持中文,但微信目前却不支持。 b、现在二维码的大小是固定,信息容量不大,如果信息量过大就不好识别,61*61的话在100个字以内,89*89的话在250个字以内,129的话在500个字以内, 可以在TppStMaxiCodeBarcode.Create设置长宽实现。参考《QRCode_编码解码标准.pdf》第13页表格对照。 James 20190427 QQ:825818689
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值