Hello all,
I am having problems in highlighting the found text in a DBMemo (Delphi
v1.0)
The procedures below find the text, but the highlighting is "Off
Target",.
For instance, if the search was for "Target Text" and the text in a
DBmemo's record was "I am searching for the Target Text in a DBMemo" ..
The code below finds the text, but highlights "xt in a DBMemo"?
Can someone please point out my error?
Here's the code
<BEGIN><CODE SNIP>
{TextToFind is a global var}
{--------------------------------------------------------------------}
function TMainForm.FindText(aString : String) : Boolean;
var
I : Integer;
begin
Result := False;
for I := 0 to DiaryDBMemo.Lines.Count -1 do
if Pos(aString, DiaryDBMemo.Lines.Strings[I]) > 0 then
(* String found *)
{MessageDlg('Found ' + aString, mtInformation,[mbOk], 0);}
Result := True;
TextPosition := Pos(aString, DiaryDBMemo.Lines.Strings[I]);
Progressbar.Progress := 0;
Exit;
end;
{--------------------------------------------------------------------}
procedure TMainForm.SearchDiaryBtnClick(Sender: TObject);
var
Found : Boolean;
begin
Found := False;
TextToFind := SearchStringEdit.Text;
AbortSearch := False;
FindNextBtn.Enabled := True;
StopSearchBtn.Enabled := True;
if TextToFind <= '' then
begin
StopSearchBtn.Enabled := False;
Exit;
end;
try
with DiaryTable do
begin
First;
while not EOF do
begin
Found := FindText(TextToFind);
UpdateProgressbar;
if Found then Exit else Next;
end
end;
finally
Progressbar.Progress := 0;
StopSearchBtn.Enabled := False;
if not Found then
begin
FindNextBtn.Enabled := False;
MessageDlg('"' +TextToFind + '"' + ' not found'
, mtInformation,[mbOk], 0);
Found := False;
TextToFind := '';
end
else
SelectTheText;
end;
end; {try block}
<END><CODE SNIP>
--
Any help would be greatly appreciated!
Rkr
--
\|||/
/'^'\
( 0 0 )
-----oOOO--(_)--OOOo----------
Reid Roman
E-Mail : rkro...@pacbell.net
Delphi Enthusiast, Hobbiest ..
U.S.A
------------------------------