Fórum Posicionar cursor em uma determinada string #253501
06/10/2004
0
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.
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
Curtir tópico
+ 0
Responder
Posts
06/10/2004
Osocram
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.
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.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)