教程中有几行代码,不能理解其意,特来请教。unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Button1: TButton;
    FindDialog1: TFindDialog;
    procedure Button1Click(Sender: TObject);
    procedure FindDialog1Find(Sender: TObject);
      private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
finddialog1.Position:= point (richedit1.Left+ richedit1.Width,richedit1.top);
finddialog1.execute;
end;
procedure TForm1.FindDialog1Find(Sender: TObject);
var
foundat : longint;
startpos,toend : integer;
begin
with richedit1 do
begin
if sellength <> 0 then
startpos :=selstart +sellength
else
startpos:= 0;
toend := length(text) -startpos;//??/
foundat :=findtext(finddialog1.findtext,startpos,toend,[stmatchcase]);//这个地方不明白干什么//
if foundat <> -1 then
begin
setfocus;//??//
selstart := foundat;//??//
sellength := length (finddialog1.findtext);//??//
end;
end;
end;
end.

解决方案 »

  1.   

    有的地方看不明白,按顺序说,共5处:
    1.如果richedit1中的text的length为0,将光标移到第一位置;
    2.打开text文本;
    3.使获得焦点,说俗一点,让光标在那里闪;
    4.将文本贴进去;
    5.增加文本长度,更新记录.
    如果说的不对,请高手吧~~~~~~~~~~~~~
      

  2.   

    toend := length(text) -startpos;//获取选择文本段之后的所有文本的长度
    foundat :=findtext(finddialog1.findtext,startpos,toend,[stmatchcase]);
    //查找选择文本段之后的所有文本
    setfocus;//设置文本框焦点
    selstart := foundat;//设置文本开始点为查找的文本的位置
    sellength := length (finddialog1.findtext);//设置选择文本的长度为查询文本的长度。