怎样在在memo或richedit控件里查找指定字符串,并将它们变颜色显示?(0分)

  • 主题发起人 yuking_cc
  • 开始时间
Y

yuking_cc

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在在memo或richedit控件里查找指定字符串,并将它们变颜色显示?
 
Delphi的例子(RichEdit)中有现成的答案。
 
var
FoundAt: LongInt;
StartPos, ToEnd: Integer;
begin
with RichEdit1 do
begin
{ begin the search after the current selection if there is one }
{ otherwise, begin at the start of the text }
if SelLength <> 0 then
StartPos := SelStart + SelLength
else
StartPos := 0;
ToEnd := Length(Text) - StartPos;
FoundAt := FindText('要查找的字符串', StartPos, ToEnd, [stMatchCase]);
if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt;
SelLength := Length('要查找的字符串');
end;
end;
 
Delphi帮助里拷的呵呵
 
发现DELPHI里的这个例子在WIN2000下没起作用,不知为什么,在多台WIN2000下试过,
在NT4.0下却可以。有没有人在WIN200下试过?
 
顶部