TRichView中文文档

TRichView 是Delphi/C++Builder  控件,主要用于显示、编辑和打印超文本文档。

新版本解决多个兼容性问题,更新了字符串标签、剪贴板、RTF和DB组件。

附:TRichView v14版下载

兼容性问题

 Item tags是字符串,不再是整数型

 OnRVFPictureNeeded参数改变

 TRichView.LoadText, LoadTextFromStream, SaveText, SaveTextToStream, TRichViewEdit.InsertTextFromFile 有了新的参数。

 TRVLongOperation的声明类型已经改变

 以下全局变量从RVTable.pas中移除:RichViewTableGridStyle, RichViewTableGridStyle2, RichViewTableGridColor,被替换为TRVStyle属性。

风格模板

 默认情况下,风格模板不能被使用,需激活风格模板,设置TRichView.UseStyleTemplates = True。

 在TRichViewEdit中,你可以应用指定的模板样式到选定区域,使用这些方法:ApplyStyleTemplate, ApplyTextStyleTemplate, ApplyParaStyleTemplate. 样式模板可用ChangeStyleTemplates方法编辑。

RTF

 TRichView.RTFOptions中的新选项:rvrtfSavePngAsPng。如果默认有这个选项,PNG图像也会被保存为PNG格式。

打印

 表格行的新属性: KeepTogether;

 新的表格方法: SetRowPageBreakBefore, SetRowKeepTogether;

 table.PrintOptions新选项: rvtoContinue;

 新属性:TCustomRVPrint.IgnorePageBreaks。

旋转

 表格单元格可旋转 90°, 180°或 270。

 一个新的方法返回项坐标: GetItemCoordsEx; 它考虑到了单元格的旋转。

字符串标签

 新属性:cell tags;

 从13.2版本开始,项目标签是字符串(Unicode for Delphi 2009或更高,ANSI老版本的Delphi),从整数到PChar无需类型转换!

64-bit

 32-bit 和 64-bit编译器均支持RAD Studio XE2+。

 注意: TRVOfficeConverter 可以编译为64-bit应用程序,但列表的转换器将为空 (因为转换器是32-bit DLLs,不能再64-bit应用中使用)。

HTML存储

 TRichView.SaveHTMLEx可保存扩展的背景图像;

 TRichView.SaveHTMLEx 能更好的保存列表标记 (无论是在常规或rvsoMarkersAsText 模式);

 TRichView.OnSaveImage2事件新增"hidden"参数。

DB组件

 如果rvfoLoadBack在 RVFOptions中, TDBRichView会在加载数据前清空 BackgroundBitmap;

 如果rvfoLoadBack在RVFOptions 和 FieldFormat=rvdbRVF中, TDBRichViewEdit会在加载数据前清空 BackgroundBitmap。

剪贴板

 TRichViewEdit 可以粘贴URL,新增方法:PasteURL;

 新属性:AcceptPasteFormats允许限制格式列表;

 新属性:DefaultPictureVAlign定义一个对齐以粘贴和放置图像。

RichEdit的实现MSNQQ 中的动画表情

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComCtrls, RxRichEd, ImageOleLib_TLB;
//RxRichEd单元是Rxlib下的RxRichEdit,一套增强功能的RichEdit
//ImageOleLib_TLB是从qq的ImageOle.dll引入的类型库
const
IID_IOleObject: TGUID = (
D1: $; D2: $; D3: $; D4: ($C0, $, $, $, $, $, $,
$));
EM_GETOLEINTERFACE = WM_USER + ;
type
TForm1 = class(TForm)
Button1: TButton;
Editor: TRxRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
FRTF: IRichEditOle;
FLockBytes: ILockBytes;
FStorage: ISTORAGE;
FClientSite: IOLECLIENTSITE;
m_lpObject: IOleObject;
m_lpAnimator: TGifAnimator;
i_GifAnimator: IGifAnimator;
reobject: TReObject;
clsid: TGuid;
sizel: tagSize;
dwStart, dwEnd: DWORD;
Rect:TRect;
begin
try
if CreateILockBytesOnHGlobal(, True, FLockBytes) <> S_OK then
begin
showmessage('Error to create Global Heap');
exit;
end;
//建立一个混合文档存取对象
if StgCreateDocfileOnILockBytes(FLockBytes, STGM_SHARE_EXCLUSIVE or
STGM_CREATE or STGM_READWRITE, , FStorage) <> S_OK then
begin
Showmessage('Error to create storage');
exit;
end;
//取得RichEdit的接口
Sendmessage(Editor.handle,EM_GETOLEINTERFACE,,LongInt(@FRTF)); if FRTF.GetClientSite(FClientSite)<>S_OK then
begin
ShowMessage('Error to get ClentSite');
Exit;
end;
CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
m_lpAnimator := TGifAnimator.Create(Self);
i_GifAnimator := m_lpAnimator.ControlInterface;
i_GifAnimator.LoadFromFile('c:\ti.gif');
i_GifAnimator.QueryInterface(IID_IOleObject, m_lpObject);
OleSetContainedObject(m_lpObject, True);
FillChar(ReObject, SizeOf(ReObject), );
ReObject.cbStruct := SizeOf(ReObject);
m_lpObject.GetUserClassID(clsid);
ReObject.clsid := clsid;
reobject.cp := REO_CP_SELECTION;
//content, but not static
reobject.dvaspect := DVASPECT_CONTENT;
//goes in the same line of text line
reobject.dwFlags := REO_BELOWBASELINE; //REO_RESIZABLE |
reobject.dwUser := ;
//the very object
reobject.poleobj := m_lpObject;
//client site contain the object
reobject.polesite := FClientSite;
//the storage
reobject.pstg := FStorage;
sizel.cx := ;
sizel.cy := ;
reobject.sizel := sizel;
//Sel all text
SendMessage(Editor.Handle, EM_SETSEL, , -);
SendMessage(Editor.Handle, EM_GETSEL, dwStart, dwEnd);
SendMessage(Editor.Handle, EM_SETSEL, dwEnd + , dwEnd + );
//Insert after the line of text
FRTF.InsertObject(reobject);
SendMessage(Editor.Handle, EM_SCROLLCARET, , );
//VARIANT_BOOL ret;
//do frame changing
m_lpAnimator.TriggerFrameChange();
//show it
m_lpObject.DoVerb(OLEIVERB_UIACTIVATE, Nil, FClientSite, , Editor.Handle,Rect);
// m_lpObject.DoVerb(
m_lpObject.DoVerb(OLEIVERB_SHOW, Nil, FClientSite, , Editor.Handle, Rect);
//redraw the window to show animation
redrawwindow(Handle, nil, , RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ERASENOW orRDW_ALLCHILDREN);
finally
FRTF:=nil;
FClientSite := nil;
FStorage :=nil;
end;
end;
end.

SetTargetToSelection

procedure TChildFrm.SetTargetToSelection(const Target: String);
var
i, StartNo, EndNo, StartOffs, EndOffs: Integer;
rveC: TCustomRichViewEdit;
begin
{ Important: when working with the selection item indices, always use
TopLevelEditor. }
rveC := rve.TopLevelEditor;
{ Receiving the range of selected items }
rveC.GetSelectionBounds(StartNo, StartOffs, EndNo, EndOffs, True);
{ If nothing is selected, exiting }
if StartNo < then
exit;
{ May be the outermost items are not included in the selection? In this case,
excluding them }
if StartOffs >= rveC.GetOffsAfterItem(StartNo) then
inc(StartNo);
if EndOffs <= rveC.GetOffsBeforeItem(EndNo) then
dec(EndNo);
{ Changing tags of the selected items }
rveC.BeginUndoGroup(rvutTag);
rveC.SetUndoGroupMode(True);
if Target <> '' then
for i := StartNo to EndNo do
rveC.SetItemTagEd(i, Target)
else
for i := StartNo to EndNo do
rveC.SetItemTagEd(i, '');
rveC.SetUndoGroupMode(false);
end;

解决RichViewEdit乱码问题

⑴ 设置RichViewEdit下面的几个属性:

① RTFReaderProperties → ParaStyleMode → rvrsAddIfNeeded

② RTFReaderProperties → TextStyleMode → rvrsAddIfNeeded

③ RTFReaderProperties → UnicodeMode → rvruOnlyUnicode

⑵ 设置RVStyle:

双击该控件,在弹出的窗体里选定里面5个子项,然后在属性窗体里找到

Unicode属性,全部改为:True;

RichView的更多相关文章

  1. fastreport 如何 设置 richview 的 行高

    richview中的行高改变有点特别.必须在AfterData 事件执行的时候才能修改: 也就是说,如果简单的放一个按钮,去发送消息给richView->RichEdit ,然后调用frxRep ...

  2. delphi RichView的使用介绍

    RichView 组件 由 9 个组件模块组成,分别是: 1.TRVStyle:主要是定义RICHVIEW样式,定义后,其它RIHCVIEW都可以引用此样式.  2.TRichView :主要用于显示 ...

  3. cocos代码研究(26)Widget子类RichView学习笔记

    理论部分 一个显示多个RichElement的容器类. 我们可以使用它很容易显示带图片的文本,继承自 Widget. 代码实践 static RichText * create ()创建一个空的Ric ...

  4. Richview 首页 奇偶页 不同页眉页脚

    首页 奇偶页 不同页眉页脚 ScaleRichView v6.0 Different headers and footers for the first page, for odd and even ...

  5. BCB6中SCALERICHVIEW加入GIF动画

    记载下,花了不少时间. 1.  项目导入文件GIFImage.pas 来源:http://melander.dk/delphi/gifimage/ 2.  项目导入文件RVGifAnimate.pas ...

  6. iOS swift 富文本显示 富文本在iOS中使用场景和解决方案

    项目中很多地方都会用到富文本的内容:比如一般的商品详情,视频详情,资讯详情等,运营人员通过后台的富文本编辑器编辑的内容,前端拿到的就是一段富文本的字符串,这富文本大多都是图片和文字的组合.我们今天介绍 ...

随机推荐

  1. bzoj 2435

    http://www.lydsy.com/JudgeOnline/problem.php?id=2435 noi 你为什么那么diao, 这种世纪水题刷一道少一道啊... 我原来还以为是两边的联通块大 ...

  2. UNP学习第五章

    一.概述 想要写一个完整的TCP客户-服务器程序例子,有下面功能的回射服务器 1.客户从标准输入读一行文本,写到服务器上: 2.服务器从网络输入读此行,并回射给客户: 3.客户读此回射行并写到标准输出 ...

  3. USB驱动程序设计

    1.USB驱动模型 ①USB HOST控制器驱动 ②USBhexin ③USB客户端驱动 设备4个层次:设备(device).配置(Config).接口(Interface).端点(Endpoint) ...

  4. paper 133:结构张量Structure Tensor(一)

    1.结构张量的作用:       能够区分图像中的平坦区域,边缘,角点: 2.图像中的结构张量的定义    1)是一个矩阵:    2)与图像的水平,垂直梯度有关,定义如下: 在MATLAB中,可以用 ...

  5. Monkeyrunner学习

    可以写一个pyhon工程,安装在android进行测试,还可以截屏操作.Monkeyrunner为framework层开发.MonkeyRunner本身是Java做的,为了和Python连接,做了一个 ...

  6. [CSP-S模拟测试]:简单的区间(分治)

    题目描述 给定一个长度为$n$的序列$a$以及常数$k$,序列从$1$开始编号.记$$f(l,t)=\sum \limits_{i=l}^ra_i-\max \limits_{i=l}^r\{a_i\ ...

  7. horizontalAccuracy 检测定位成功

    - (void)findCurrentLocation { self.isFirstUpdate = YES; [self.locationManager startUpdatingLocation] ...

  8. struts2 paramsPrepareParamsStack拦截器简化代码(源码分析)

    目录 一.在讲 paramsPrepareParamsStack 之前,先看一个增删改查的例子. 1. Dao.java准备数据和提供增删改查 2. Employee.java 为model 3. E ...

  9. php开发面试题---Redis和Memcache区别,优缺点对比

    php开发面试题---Redis和Memcache区别,优缺点对比 一.总结 一句话总结: Redis相当于Memcache的扩展,增加比如持久化.多种数据结构.集群分布式功能 反思的回顾非常有用,因 ...

  10. The request with exception: The SSL connection could not be established, see inner exception. requestId 解决方案

    DOTNET CORE 部署 Centos7 抛出异常 环境变量如下: .NET Core SDK (reflecting any global.json): Version: 2.2.401 Com ...