Difference between revisions of "TReplaceDialog"
From Free Pascal wiki
Jump to navigationJump to searchLine 4: | Line 4: | ||
== Usage == | == Usage == | ||
+ | An example to use a [[TReplaceDialog]] with a [[TSynEdit]]. The <tt>OnReplace</tt> | ||
+ | |||
<syntaxhighlight> | <syntaxhighlight> | ||
procedure TMyForm.Button1Click(Sender: TObject); | procedure TMyForm.Button1Click(Sender: TObject); | ||
Line 12: | Line 14: | ||
procedure TMyForm.ReplaceDialog1Replace(Sender: TObject); | procedure TMyForm.ReplaceDialog1Replace(Sender: TObject); | ||
var | var | ||
− | |||
k: integer; | k: integer; | ||
− | |||
begin | begin | ||
with Sender as TReplaceDialog do begin | with Sender as TReplaceDialog do begin | ||
− | if frReplace in Options then | + | opt := []; |
− | + | if frReplace in Options then | |
− | + | opt := [ssoReplace]; | |
− | + | if frReplaceAll in Options then | |
− | + | opt := [ssoReplaceAll]; | |
− | + | k := TSynEdit1.SearchReplaceEx( FindText, ReplaceText, opt, Position ); | |
− | + | if k>=0 then | |
− | + | TSynEdit1.SetFocus() | |
− | + | else | |
− | + | Beep(); | |
− | |||
end; | end; | ||
end; | end; | ||
Line 34: | Line 33: | ||
== See also == | == See also == | ||
* [[doc:lcl/dialogs/treplacedialog.html|TReplaceDialog doc]] | * [[doc:lcl/dialogs/treplacedialog.html|TReplaceDialog doc]] | ||
+ | * [[TFindDialog]] | ||
{{LCL Components}} | {{LCL Components}} |
Revision as of 12:53, 11 September 2016
TReplaceDialog is a component that aids in search and replace textinformation. It can be found on the Dialogs tab of the Component Palette.
Usage
An example to use a TReplaceDialog with a TSynEdit. The OnReplace
procedure TMyForm.Button1Click(Sender: TObject);
begin
ReplaceDialog1.Execute();
end;
procedure TMyForm.ReplaceDialog1Replace(Sender: TObject);
var
k: integer;
begin
with Sender as TReplaceDialog do begin
opt := [];
if frReplace in Options then
opt := [ssoReplace];
if frReplaceAll in Options then
opt := [ssoReplaceAll];
k := TSynEdit1.SearchReplaceEx( FindText, ReplaceText, opt, Position );
if k>=0 then
TSynEdit1.SetFocus()
else
Beep();
end;
end;
See also