教程中有几行代码,不能理解其意,特来请教。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.
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.
解决方案 »
- 用DBGrid显示多集合数据,运行时也通过,但是就是不在DBgrid中显示?
- 怎么记录不能显示?
- 有谁知道用什么控件可以制作产生lisence验证程序是不是正版?
- Access远程连接后如何断开
- 关于try...Except的问题
- 新添Form时会自动加到Auto-Create Forms里面,程序一运行就创建,很烦,有没有避免之道?
- 关于CHARTFX在ACTIVEFORM中发布的问题
- 如何将123转化为壹贰叁!(急!!!在线等待)
- 嵌入word的activex 透明问题
- 请大家介绍一些比较好的DELPHI网站好吗?谢谢
- 啊!暴跳!sql 语句问题!
- QuickReport如何实现在固定数量行没有记录时打印空行(不用插入空记录的方法)?
1.如果richedit1中的text的length为0,将光标移到第一位置;
2.打开text文本;
3.使获得焦点,说俗一点,让光标在那里闪;
4.将文本贴进去;
5.增加文本长度,更新记录.
如果说的不对,请高手吧~~~~~~~~~~~~~
foundat :=findtext(finddialog1.findtext,startpos,toend,[stmatchcase]);
//查找选择文本段之后的所有文本
setfocus;//设置文本框焦点
selstart := foundat;//设置文本开始点为查找的文本的位置
sellength := length (finddialog1.findtext);//设置选择文本的长度为查询文本的长度。