Sign in Join
Wiki copytemporary

TReplaceDialog/zh CN: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TReplaceDialog/zh CN

OldNewLine
1+**TReplaceDialog** ![](/wiki-images/2/2d/Treplacedialog.png) 替换内容的控件. 在 [[Dialogs tab]] 的 [[Component Palette]].
2+
3+![](/wiki-images/2/20/Component-TReplaceDialog.png)\]\]
4+
5+## 用法
6+
7+示例:使用 [[TReplaceDialog]] 和 [[TSynEdit]]. `OnReplace` 属性在按下替换按钮后执行.
8+
9+``` pascal
10+uses
11+SynEditTypes,
12+var
13+opt: TSynSearchOptions;
14+
15+//......
16+
17+procedure TMyForm.Button1Click(Sender: TObject);
18+begin
19+ ReplaceDialog1.Execute();
20+end;
21+
22+procedure TMyForm.ReplaceDialog1Replace(Sender: TObject);
23+var
24+ k: integer;
25+begin
26+ with Sender as TReplaceDialog do begin
27+ opt := [];
28+ if frReplace in Options then
29+ opt := [ssoReplace];
30+ if frReplaceAll in Options then
31+ opt := [ssoReplaceAll];
32+ k := SynEdit1.SearchReplaceEx( FindText, ReplaceText, opt, Position );
33+ if k>=0 then
34+ SynEdit1.SetFocus()
35+ else
36+ Form1.Caption := '...';
37+ end;
38+end;
39+```
40+
41+## 参考资料
42+
43+- [[doc:lcl/dialogs/treplacedialog.html|TReplaceDialog doc]]
44+- [[TFindDialog]]
45+
46+---
47+*From the Free Pascal wiki, page "TReplaceDialog/zh CN", as it stood on 2020-05-02 after a change by TyphonFinger, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history