怎樣用Delphi中提供的Finddialog和ReplaceDialog對話框?

Reaky 2002-08-14 01:08:52
為什麼我Excute後,輸入查找條件他就是找不到呢?也許根本就沒有去找。
...全文
413 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
delme_now 2002-12-09
  • 打赏
  • 举报
回复
关注:Memo1中如何作。
tigerchina 2002-08-15
  • 打赏
  • 举报
回复
你要Replace得话可用SetSelTextBuf
tigerchina 2002-08-15
  • 打赏
  • 举报
回复
高亮顯示要你自己做
如例子中的
if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt;
SelLength := Length(FindDialog1.FindText);
end;
cdimp 2002-08-15
  • 打赏
  • 举报
回复
关注
Reaky 2002-08-15
  • 打赏
  • 举报
回复
幫幫忙,我就是用的這個例子,可是不行。比如我們平時查找的時候,當找到時會高亮顯示找到的字符,並在可以Replace All,但是那兩個控件好像做不到,不知為什麼?沒有用過的人嗎?
tigerchina 2002-08-14
  • 打赏
  • 举报
回复
请参看FindDialog.Execute的例子
This example requires a TRichEdit, a TButton, and a TFindDialog.
Clicking the button click will display a Find Dialog to the right of the edit control. Filling in the "Find what" text and pressing the Find Next button will select the first matching string in the Rich Edit control that follows the previous selection.

procedure TForm1.Button1Click(Sender: TObject);

begin
FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
FindDialog1.Execute;
end;

procedure TForm1.FindDialog1Find(Sender: TObject);
var
FoundAt: LongInt;
StartPos, ToEnd: Integer;
begin
with RichEdit1 do
begin
{ begin the search after the current selection if there is one }
{ otherwise, begin at the start of the text }
if SelLength <> 0 then

StartPos := SelStart + SelLength
else

StartPos := 0;

{ ToEnd is the length from StartPos to the end of the text in the rich edit control }

ToEnd := Length(Text) - StartPos;

FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]);
if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt;
SelLength := Length(FindDialog1.FindText);
end;
end;
end;
forfoo 2002-08-14
  • 打赏
  • 举报
回复
你的Delphi有问题哦
不可能的嘛
finddialog.excute
dejoy 2002-08-14
  • 打赏
  • 举报
回复
关注

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧