本帖最后由 冥界3大法王 于 2024-3-13 10:56 编辑
没求人,自己憋会的。
我自己比较喜欢这个公司的富文本控件 ,RichView
虽然有更简单的ActionList,但是对生成的DLL中调用竟然抽风。
折腾了一晚上,到现在才折腾成功,所以分享一下:
[Delphi] 纯文本查看 复制代码 unit Unit7;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, RVScroll, RichView, RVEdit, RVUniscribeGrIn, RVStyle,
RichViewActions, System.Actions, Vcl.ActnList;
type
TForm7 = class(TForm)
ActionList1: TActionList;
RVEEditrvActionFind1: TrvActionFind;
RVEEditrvActionFindNext1: TrvActionFindNext;
RVEEditrvActionReplace1: TrvActionReplace;
RVStyle1: TRVStyle;
RichViewEdit1: TRichViewEdit;
Button1: TButton;
Button2: TButton;
ReplaceDialog1: TReplaceDialog;
查找替换: TButton;
procedure ReplaceDialog1Find(Sender: TObject);
procedure ReplaceDialog1Replace(Sender: TObject);
procedure 查找替换Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
uses
RVMisc;
procedure TForm7.ReplaceDialog1Find(Sender: TObject);
begin
if not RichViewEdit1.SearchText(ReplaceDialog1.FindText, GetRVESearchOptions(ReplaceDialog1.Options)) then
Application.MessageBox('没有找到!', '搜索完成!', MB_OK or MB_ICONEXCLAMATION)
end;
procedure TForm7.查找替换Click(Sender: TObject);
begin
ReplaceDialog1.Execute;
end;
procedure TForm7.ReplaceDialog1Replace(Sender: TObject);
var
ZZZ: Integer;
begin
if frReplace in ReplaceDialog1.Options then //一个一个的替换
begin
//ShowMessage('您点击的是【替换】按钮');
RichViewEdit1.InsertText(ReplaceDialog1.ReplaceText);
RichViewEdit1.Format;
end
else if frReplaceAll in ReplaceDialog1.Options then //全部替换
begin
//ShowMessage('您点击的是【替换全部】按钮');
while RichViewEdit1.SearchText(ReplaceDialog1.FindText, GetRVESearchOptions(ReplaceDialog1.Options)) do
begin
RichViewEdit1.InsertText(ReplaceDialog1.ReplaceText, False);
inc(ZZZ);
end;
end;
end;
end.
|