It's common to have 2 different search menu options: Find (CTR+F), and then Find Again (F3)
I didn't see a built-in easy way of doing this, so this is what I did on the form with the TAdvMemoFindDialog and requesting to have something like this built-into TAdvMemo/TAdvFindDialog
TAdvMemoFindDialog = class(AdvMemo.TAdvMemoFindDialog)
private
fLastFindText:string;
fSearchingPreviousDirection:Boolean;
protected
procedure FindDir(prev: boolean); override;
public
procedure FindNext;
procedure ClearLastFind;
end;
procedure TAdvMemoFindDialog.FindDir(prev: boolean);
begin
fSearchingPreviousDirection := Prev;
fLastFindText := FindDialog.FindText; //need access to FFindDialogEx + FFindDialog
inherited;
end;
procedure TAdvMemoFindDialog.FindNext;
begin
if fLastFindText.Length > 0 then
begin
FindDialog.FindText := fLastFindText;
FindDir(fSearchingPreviousDirection);
end;
end;
procedure TAdvMemoFindDialog.ClearLastFind;
begin
fLastFindText := '';
end;
Then you can support Find, Find Again:
procedure TMemoEditorFrame.HandleSearchFindAction;
begin
AdvMemoFindDialog1.Execute;
end;
procedure TMemoEditorFrame.HandleSearchFindAgainAction;
begin
AdvMemoFindDialog1.FindNext;
end;
If the document is cleared, you can call
AdvMemoFindDialog1.ClearLastFind;
The F3 hotkey then is bound to the Find Next menu and the Find Dialog isn't displayed, but the search continues as expected.