Difference between revisions of "TReplaceDialog/zh CN"
From Free Pascal wiki
Jump to navigationJump to searchTyphonFinger (talk | contribs) (Created page with "{{TReplaceDialog}} '''TReplaceDialog''' Image:treplacedialog.png 替换内容的控件. 在 Dialogs tab 的 Component Palette. image:component-TReplaceDialog.p...") |
TyphonFinger (talk | contribs) |
||
Line 10: | Line 10: | ||
<syntaxhighlight lang=pascal> | <syntaxhighlight lang=pascal> | ||
+ | uses | ||
+ | SynEditTypes, | ||
+ | var | ||
+ | opt: TSynSearchOptions; | ||
+ | |||
+ | //...... | ||
+ | |||
procedure TMyForm.Button1Click(Sender: TObject); | procedure TMyForm.Button1Click(Sender: TObject); | ||
begin | begin | ||
Line 25: | Line 32: | ||
if frReplaceAll in Options then | if frReplaceAll in Options then | ||
opt := [ssoReplaceAll]; | opt := [ssoReplaceAll]; | ||
− | k := | + | k := SynEdit1.SearchReplaceEx( FindText, ReplaceText, opt, Position ); |
if k>=0 then | if k>=0 then | ||
− | + | SynEdit1.SetFocus() | |
else | else | ||
− | + | Form1.Caption := '...'; | |
end; | end; | ||
end; | end; |
Latest revision as of 16:55, 2 May 2020
│
English (en) │
français (fr) │
русский (ru) │
中文(中国大陆) (zh_CN) │
TReplaceDialog 替换内容的控件. 在 Dialogs tab 的 Component Palette.
用法
示例:使用 TReplaceDialog 和 TSynEdit. OnReplace 属性在按下替换按钮后执行.
uses
SynEditTypes,
var
opt: TSynSearchOptions;
//......
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 := SynEdit1.SearchReplaceEx( FindText, ReplaceText, opt, Position );
if k>=0 then
SynEdit1.SetFocus()
else
Form1.Caption := '...';
end;
end;
参考资料