您现在的位置是: 软件 > 设计在线 > 网页陶吧 > 技术平台 > HTML学习 > 正文


-Win xp中的多种网络
-试验试验试验试验
-用Freehand实现位图矢量化
-网络电话面面观

RichEdit中实现查找功能
2000-08-09· ·-··逸仙时空

  RichEdit有一个FindText函数,极大方便了我们为RichEdit编制查找功能。下面的片断取自于Delphi帮助中的范例。

C++ Builder

请参照Delphi的例子

Delphi

procedure TMainForm.FindDialogFind(Sender: TObject);

var

FoundAt: LongInt;

StartPos, ToEnd: integer;

SearchFlag: TSearchTypes;

begin

if frMatchCase in FindDialog.Options then

SearchFlag:=[stMatchCase];

if frWholeWord in FindDialog.Options then

SearchFlag:=SearchFlag+[stWholeWord];

with RichEdit do

begin

StartPos:=SelStart+SelLength;

ToEnd:=Length(Text) - StartPos;

FoundAt:=FindText(FindDialog.FindText, StartPos, ToEnd, [stMatchCase]);

if FoundAt<>-1 then

begin

SetFocus;

SelStart:=FoundAt;

SelLength:=Length(FindDialog.FindText);

end

else

begin

SelLength:=0;

SelStart:=StartPos;

Application.MessageBox(PChar(找不到+FindDialog.FindText),查找失败,0);

end;

end;

end;

■ 相关内容
感谢 访问天极网,如果您觉得该文章涉及版权问题,请看这里!