Difference between revisions of "TReplaceDialog"
From Free Pascal wiki
Jump to navigationJump to searchm (Fixed syntax highlighting) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{TReplaceDialog}} | ||
+ | |||
'''TReplaceDialog''' [[Image:treplacedialog.png]] is a component that aids in search and replace textinformation. It can be found on the [[Dialogs tab]] of the [[Component Palette]]. | '''TReplaceDialog''' [[Image:treplacedialog.png]] is a component that aids in search and replace textinformation. It can be found on the [[Dialogs tab]] of the [[Component Palette]]. | ||
Line 4: | Line 6: | ||
== Usage == | == Usage == | ||
− | <syntaxhighlight> | + | |
− | procedure | + | An example to use a [[TReplaceDialog]] with a [[TSynEdit]]. The <tt>OnReplace</tt> will be executed when the 'Replace' button within the dialog is pressed. |
+ | |||
+ | <syntaxhighlight lang=pascal> | ||
+ | procedure TMyForm.Button1Click(Sender: TObject); | ||
begin | begin | ||
− | ReplaceDialog1. | + | 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; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== See also == | == See also == | ||
+ | |||
* [[doc:lcl/dialogs/treplacedialog.html|TReplaceDialog doc]] | * [[doc:lcl/dialogs/treplacedialog.html|TReplaceDialog doc]] | ||
+ | * [[TFindDialog]] | ||
{{LCL Components}} | {{LCL Components}} |
Latest revision as of 12:05, 1 March 2020
│
English (en) │
français (fr) │
русский (ru) │
中文(中国大陆) (zh_CN) │
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 will be executed when the 'Replace' button within the dialog is pressed.
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