Difference between revisions of "TFindDialog"
From Free Pascal wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
'''TFindDialog''' [[Image:tfinddialog.png]] is a component that aids in finding information. It can be found on the [[Dialogs tab]] of the [[Component Palette]]. | '''TFindDialog''' [[Image:tfinddialog.png]] is a component that aids in finding information. It can be found on the [[Dialogs tab]] of the [[Component Palette]]. | ||
+ | |||
+ | To activate a FindDalilog, just call its <tt>Execute()</tt> function. Create an <tt>OnFind</tt> method to perform the actual find. | ||
[[image:component-TFindDialog.png]] | [[image:component-TFindDialog.png]] | ||
Line 5: | Line 7: | ||
== Usage == | == Usage == | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | procedure | + | procedure TMyForm.Button1Click(Sender: TObject); |
+ | begin | ||
+ | FindDialog1.FindText := 'findme'; | ||
+ | FindDialog1.Execute(); | ||
+ | end; | ||
+ | |||
+ | procedure TMyForm.FindDialog1Find(Sender: TObject); | ||
var | var | ||
− | + | src: String; | |
begin | begin | ||
− | + | with Sender as TFindDialog do begin | |
− | + | src := ReplaceDialog1.FindText; | |
− | + | k := Pos( src, Memo1.Lines.Text ); | |
+ | if k>0 then begin | ||
+ | Memo1.Selstart := k; | ||
+ | Memo1.SelLength := length( src ); | ||
+ | end else | ||
+ | Beep(); | ||
+ | end; | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 11:31, 11 September 2016
TFindDialog is a component that aids in finding information. It can be found on the Dialogs tab of the Component Palette.
To activate a FindDalilog, just call its Execute() function. Create an OnFind method to perform the actual find.
Usage
procedure TMyForm.Button1Click(Sender: TObject);
begin
FindDialog1.FindText := 'findme';
FindDialog1.Execute();
end;
procedure TMyForm.FindDialog1Find(Sender: TObject);
var
src: String;
begin
with Sender as TFindDialog do begin
src := ReplaceDialog1.FindText;
k := Pos( src, Memo1.Lines.Text );
if k>0 then begin
Memo1.Selstart := k;
Memo1.SelLength := length( src );
end else
Beep();
end;
end;
See also