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. 分布式存储Ceph之PG状态详解

    https://www.jianshu.com/p/36c2d5682d87 1. PG介绍 继上次分享的<Ceph介绍及原理架构分享>,这次主要来分享Ceph中的PG各种状态详解,PG是 ...

  2. Qt 无法连接mysql数据库的问题

    错误信息: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL ...

  3. POJ 3159 Candies(spfa、差分约束)

    Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the he ...

  4. iOS 获取self类型

    类型转换快速写法 typeof(self) bself = self; 版权声明:本文为博主原创文章,未经博主允许不得转载.

  5. js实现复选框全选/全不选/反选

    js实现复选框全选/全不选/反选 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...

  6. webstorm 去点右边白线

    file>settings>editor>general>appearance>show right margin(configured in code style oo ...

  7. 04 循环结构概述和for语句的格式及其使用

    04.01_Java语言基础(循环结构概述和for语句的格式及其使用) A:循环结构的分类 for,while,do…while B:循环结构for语句的格式: for(初始化表达式;条件表达式;循环 ...

  8. mysql 个人博客应用的建表和相关查询

    一.建表 用户表tb_user create table if not exists tb_user( user_id int auto_increment, ) not null, user_pas ...

  9. 排序(分组后排序&整排)

    一.整排 要求:根据score进行排名,分数相同,名次相同,且连续 表如下图: sql语句: 方法一:select a.score, (select count(distinct b.score) f ...

  10. USACO 2014 US Open Decorating The Pastures

    题目大意: 给定n个点m条边的无向图 判断这个图能否将所有点依次染色为F J F J 若能输出最多能染多少个J 若不能输出-1 就是给一个图01染色 过程中判断是否出现不符合的情况 即点1到点2到点3 ...