Posicionar cursor em uma determinada string

Delphi

06/10/2004

Boa tarde programadores,

Estou buscando uma determinada string dentro de um campo memo de uma tabela que é mostrado em um [color=blue:93ecd85179]richedit[/color:93ecd85179]. A pesquisa está funcionando legal só que o cursor sempre fica na primeira linha do richedit e nunca na string encontrada. Como são textos muito longos, preciso que, quando a string for encontrada o foco esteja sobre ela. alguém poderia dar uma força ?

Desde já agradeço.


Vetorzero

Vetorzero

Curtidas 0

Respostas

Osocram

Osocram

06/10/2004

var globais
GBegin :integer;

Procedure TForm1.procurarPalavra;//esta var ´next´ se for true entaum a procura vai ser pelo mesma palavra
Begin

//-=-= sintaxe = function FindText(const SearchStr: string; StartPos, Length: Integer; Options: TSearchTypes): Integer;
if RichEdit1.FindText(Edit1.Text,GBeginSearch,(Length(RichEdit1.Text)-GBeginSearch),[])=-1
then mensagens(1)
else
with RichEdit1 do begin
// SetFocus;
SelStart := RichEdit1.FindText(Edit1.Text,GBeginSearch,(Length(RichEdit1.Text)-GBeginSearch),[]);
SelLength := Length(Edit1.Text);//tamanho da palavra procura
GBeginSearch:=SelStart+SelLength;
end;//with

End;//fim do procedure

procedure TForm1.FlatEdit1Change(Sender: TObject);
begin
GBeginSearch:=0;
procurarPalavra;
Edit1.SetFocus;
end;

procedure TForm1.FlatEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) and (GBeginSearch0) then begin
procurarPalavra;
end;//fim do if then
Edit1.SetFocus;
end;

end.


GOSTEI 0
POSTAR