Delphi,Rxlib,RxRichEdit,Richedit 高版本 ,Rich Text Edit Control, v4.1 控件,打印Bug

本文介绍了在Delphi中使用RxLib的RxRichEdit控件时遇到的打印问题,并提供了解决方案。RxRichEdit是封装的高版本RichEdit控件,支持插入表格和图片,但存在查找替换、中文支持和打印等问题。文章分享了从外部来源获取的修复打印问题的代码,并探讨了使用高版本RichEdit控件的原因。

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

我们知道 RichEdit 是M$提供的标准控件,delphi的vcl里面是很老的版本,而rxlib的有最新的4.1的封装

 

但是bug很多 ,比如查找替换 ,中文支持,打印等等,下面代码就是解决的打印问题,来自国外某网站,

 

自己根据情况,有调整

 

Why? ---为什么使用这个高版本呢?这个版本的RTF控件,支持插入表格(当然是用接口罗),支持从word粘贴表格

不变形,插入图片很方便,那么还有什么理由拒绝呢?

 

ExpandedBlockStart.gif 代码
// 打印rxrichedit
// 可以设置左边,上边距,单位inch
// eg:
//   printrxrichedit(editor, 0.5 , 0.5 );

unit  uPrintRxRichEdit;

interface

uses  Windows,messages,RxRichEd ,RichEdit,printers,math;

type
  TPageOffset 
=   record
    mStart,
      mEnd: Integer;
    rendRect: TRect;
  
end ;

// 打印rxrichedit
function  printRxRichEdit(editor:TRxRichEdit;leftoffset,topoffset:double):integer;

  
implementation

// 打印rxrichedit ,返回值是页数
function  printRxRichEdit(editor:TRxRichEdit;leftoffset,topoffset:double):integer;
var
  wPage, hPage, xPPI, yPPI, wTwips, hTwips: integer;
  pageRect, rendRect: TRect;
  po: TPageOffset;
  fr: TFormatRange;
  lastOffset, currPage, pageCount: integer;
  xOffset, yOffset: integer;
  FPageOffsets: 
array   of  TPageOffset;
  TextLenEx: TGetTextLengthEx;
  firstPage: boolean;
begin
  
// First, get the size  of  a printed page  in  printer device units
  wPage :
=  GetDeviceCaps(Printer.Handle, PHYSICALWIDTH);
  hPage :
=  GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT);
  
// Next, get the device units per inch  for  the printer
  xPPI :
=  GetDeviceCaps(Printer.Handle, LOGPIXELSX);
  yPPI :
=  GetDeviceCaps(Printer.Handle, LOGPIXELSY);
  
// Convert the page size from device units  to  twips
  wTwips :
=  MulDiv(wPage,  1440 , xPPI);
  hTwips :
=  MulDiv(hPage,  1440 , yPPI);
  
// Save the page size  in  twips
  
with  pageRect  do
  
begin
    Left :
=   0 ;
    Top :
=   0 ;
    Right :
=  wTwips;
    Bottom :
=  hTwi
Unofficial version Rx library for Delphi 2005/2006/2007/2009/2010/XE/XE2/XE3 DISCLAIMER: * This software is provided "as is" and is without warranty of any kind. The author(s) of this software does not warrant, guarantee or make any representations regarding the use or results of use of this software in terms of reliability, accuracy or fitness for purpose. You assume the entire risk of direct or indirect, consequential or inconsequential results from the correct or incorrect usage of this software even if the author(s) has been informed of the possibilities of such damage. Neither the author(s) nor anybody connected to this software in any way can assume any responsibility. * All rights held by the author(s) or owner(s) of units or documents. _______________________________________________________________________________ Update 1.10 1/ Update for Delphi XE3 _______________________________________________________________________________ Update 1.09 1/ Delphi package source actualization 2/ Delphi 6 conditional corections 3/ TRxFindFiles support class added 4/ Corrections for default (ENG) lang. resource _______________________________________________________________________________ Update 1.08 1/ file case name unit corrections. 2/ only one language file can be used in your applications like: a) in Rx.inc activate {$DEFINE _LNG_ONE_}. b) activate yours own language in new include RxLangDef.inc like {$DEFINE RXLANG_Cze}. note: Languages different from English locates in utf-8 files, may be editor problem for lower version Delphi than 2005. c) in your project use global conditional define like RXLANG_MYLANG (it activate your lang file only). d) rebuild your application, it will be smaller with one your language mutation for RxLibrary only. 3/ repair malfunction of TColor property (big thanks to Remy Lebeau). 4/ many new constant color names added into module RxColors (+ 229 named constant). 5/ new component TRxThread added for better access. 6/ repair malfunction of property caption editor. 7/ new components TRxAnimBitBtn, TRxAnimSpeedButton added. 8/ repair malfunction with styles in TRxProgress. 9/ refresh code in TRxDBGridSorter. 10/ adopted 20 function utilities by Alexey Popov into module RxProps. 11/ activate Align property in TRxSpinButton. 12/ rename parameter Name to AName in define event TExecOpenDialogEvent, because occur names conflict. 13/ repair conflict in string property in module RxTranslate for unicodes. 14/ some functions added into module RxVerInf for better work with versions. Note for users Delphi 5/6/7: ---------------------------- RxLibrary is not directly designed for this Delphi versions. When you will want compile source code in this versions of Delphi, you have to open all units contain form (*.dfm) and resave it for resource compatibility (crash prevent IDE) before rebuild and install into IDE. Some functionality will be lost. Note for users Delphi XE2 (64 bit.ver): --------------------------------------- This source code is 64 bit ready but untested. BDE packs must be removed from 64 bit project as unsuported technology. Note for users CBuilder: ------------------------ This source code is CBuilder (2006/2007) ready but uncomplete and untested yet. Releases February 29, 2012 _______________________________________________________________________________ Update 1.07 1/ Update all packages in unit scope. 2/ Change namespace in RxViewer unit for XE2. _______________________________________________________________________________ Update 1.06 1/ repair malfunction of TFormStorage under Unicode Delphi. 2/ update packages file for Delphi 2005 - XE. 3/ update package for Delphi XE2 32 bit. _______________________________________________________________________________ Update 1.05 1/ better compatibility with Delphi 2009. 2/ new adopted component for view any supported files. 3/ convert dfm files to text. _______________________________________________________________________________ Update 1.04 Updated: 1/ small mistake in RxDBCtrl.pas (wrong show DBGrid). 2/ activate tables in general RxDemo. 3/ replacement deprecated FileAge() in RxFileUtils. _______________________________________________________________________________ The initial release(s) no included
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值