Demo7Frm.pas
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:1k
源码类别:

RichEdit

开发平台:

Delphi

  1. unit Demo7Frm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   RVScroll, RichView, RVEdit, ExtCtrls, StdCtrls;
  6. type
  7.   TfrmDemo7 = class(TForm)
  8.     Panel1: TPanel;
  9.     rve: TRichViewEdit;
  10.     txt: TEdit;
  11.     btnMark: TButton;
  12.     btnUnmark: TButton;
  13.     procedure FormCreate(Sender: TObject);
  14.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  15.       Shift: TShiftState);
  16.     procedure btnMarkClick(Sender: TObject);
  17.     procedure btnUnmarkClick(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23. implementation
  24. uses MainFrm;
  25. {$R *.DFM}
  26. procedure TfrmDemo7.FormCreate(Sender: TObject);
  27. begin
  28.   rve.Clear;
  29.   rve.LoadText(ExtractFilePath(Application.ExeName)+'MainFrm.pas',0,0, False);
  30.   rve.Format;
  31. end;
  32. procedure TfrmDemo7.FormKeyDown(Sender: TObject; var Key: Word;
  33.   Shift: TShiftState);
  34. begin
  35.   if Key=VK_ESCAPE then Close;
  36. end;
  37. procedure TfrmDemo7.btnMarkClick(Sender: TObject);
  38. begin
  39.   rve.SetSelectionBounds(0,rve.GetOffsBeforeItem(0),0,rve.GetOffsBeforeItem(0));
  40.   while rve.SearchText(txt.Text, [rvseoDown]) do
  41.     rve.ApplyTextStyle(sncomMarked);
  42. // Note: every call of ApplyTextStyle reformats affected paragraphs
  43. end;
  44. procedure TfrmDemo7.btnUnmarkClick(Sender: TObject);
  45. begin
  46.   rve.SelectAll;
  47.   rve.ApplyTextStyle(sncomNormal);
  48.   rve.Deselect;
  49.   rve.Refresh;  
  50. end;
  51. end.