RichView

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: $00000112; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00,
    $46));
  EM_GETOLEINTERFACE                  = WM_USER + 60;
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(0, 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, 0, FStorage) <> S_OK then
  begin
    Showmessage('Error to create storage');
    exit;
  end;
  //取得RichEdit的接口
  Sendmessage(Editor.handle,EM_GETOLEINTERFACE,0,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), 0);
  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 := 0;
  //the very object
  reobject.poleobj := m_lpObject;
  //client site contain the object
  reobject.polesite := FClientSite;
  //the storage
  reobject.pstg := FStorage;
  sizel.cx := 0;
  sizel.cy := 0;
  reobject.sizel := sizel;
  //Sel all text
  SendMessage(Editor.Handle, EM_SETSEL, 0, -1);
  SendMessage(Editor.Handle, EM_GETSEL, dwStart, dwEnd);
  SendMessage(Editor.Handle, EM_SETSEL, dwEnd + 1, dwEnd + 1);
  //Insert after the line of text
  FRTF.InsertObject(reobject);
  SendMessage(Editor.Handle, EM_SCROLLCARET, 0, 0);
  //VARIANT_BOOL ret;
  //do frame changing
   m_lpAnimator.TriggerFrameChange();
  //show it
  m_lpObject.DoVerb(OLEIVERB_UIACTIVATE, Nil, FClientSite, 0, Editor.Handle,Rect);
// m_lpObject.DoVerb(
  m_lpObject.DoVerb(OLEIVERB_SHOW, Nil, FClientSite, 0, Editor.Handle, Rect);
  //redraw the window to show animation
  redrawwindow(Handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ERASENOW orRDW_ALLCHILDREN);
  finally
  FRTF:=nil;
  FClientSite := nil;
  FStorage :=nil;
  end;
end;
end.
View Code

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 < 0 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;
View Code

解决RichViewEdit乱码问题

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

  ① RTFReaderProperties → ParaStyleMode → rvrsAddIfNeeded

  ② RTFReaderProperties → TextStyleMode → rvrsAddIfNeeded

  ③ RTFReaderProperties → UnicodeMode → rvruOnlyUnicode

⑵ 设置RVStyle:

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

Unicode属性,全部改为:True; 

 

转载于:https://www.cnblogs.com/blogpro/p/11452776.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值