⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examples.txt

📁 richviewaction 1.58 需要richview 1.9.46
💻 TXT
字号:
=======================================================================
                             EXAMPLE 1
         How to implement saving and loading in HTML format.
=======================================================================

By default, RichViewActions allows to export HTML and insert it 
(with rvHtmlImporter).
This example shows how to implement opening and saving HTML files.
Use it at your own risk, because quality of RvHtmlImporter is not
guaranteed.

First, assign CustomFilter property of TrvActionOpen 
and TrvActionSaveAs.
You can do it at design time in the Object Inspector.
But if you want to make it localizable, do it at run time in 
the localization procedure (in the ActionTest project - in the procedure
TForm3.Localize):
  rvActionsResource.rvActionOpen1.CustomFilter :=  RVA_GetS(rvam_flt_HTMLOpen);
  rvActionsResource.rvActionSaveAs1.CustomFilter :=  RVA_GetS(rvam_flt_HTMLOpen);
Make sure that ffiCustom is in rvActionOpen.Filter, and
ffeCustom is in rvActionSaveAs.Filter.

Next, process RVAContolPanel.OnCustomFileOperation event:

procedure TForm3.RVAControlPanel1CustomFileOperation(Sender: TrvAction;
  Edit: TCustomRichViewEdit; const FileName: String;
  Operation: TRVAFileOperation; var SaveFormat: TrvFileSaveFilter;
  var CustomFilterIndex: Integer; var Success: Boolean);
var Stream: TFileStream;
    s: String;
begin
  case Operation of
    rvafoOpen:
      begin
        try
          // This example assumes that there is only one custom open format,
          // so it does not check CustomFilterIndex (it must be 1)
          Stream := TFileStream.Create(FileName, fmOpenRead);
          try
            SetLength(s, Stream.Size);
            Stream.ReadBuffer(PChar(s)^, Length(s));
          finally
            Stream.Free;
          end;
          RvHtmlImporter1.RichView := Edit;
          RvHtmlImporter1.LoadHtml(s);
          // This example assumes that there is only one custom save format,
          // so it does not assign CustomFilterIndex and SaveFormat
          // (they are already 1 and ffeCustom correspondingly)
          Success := True;
        except;
          Success := False;
        end;
      end;
    rvafoSave:
      begin
          // This example assumes that there is only one custom save format,
          // so it does not check CustomFilterIndex (it must be 1)      
          Success := Edit.SaveHTML(FileName, rvActionsResource.rvActionExport1.FileTitle,
            rvActionsResource.rvActionExport1.ImagePrefix,
            rvActionsResource.rvActionExport1.SaveOptions+[rvsoOverrideImages]);
      end;
  end;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -