unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, jpeg, ExtCtrls;

type
  TForm2 = class(TForm)
    Button2: TButton;
    Edit1: TEdit;
    RichEdit1: TRichEdit;
    Button3: TButton;
    Image1: TImage;
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}


procedure TForm2.Button2Click(Sender: TObject);

var T:integer;
begin

T := Richedit1.FindText(Edit1.Text, 0, length(Richedit1.Text), [stMatchCase]);

  if(T > 0) then
  begin
    Richedit1.HideSelection := false;
    Richedit1.SelStart := Length(Richedit1.Text)-1;
    Richedit1.SelLength := 1;
    Richedit1.Focused;
    Richedit1.SelStart := T;
    Richedit1.SelLength := Length(Edit1.Text);
    Richedit1.Focused;
    Richedit1.HideSelection := true;
  end;
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
Close;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
RichEdit1.Lines.LoadFromFile('Справка.rtf');
end;

end.
 