Setfocus in edit box of TFindDialog

When executing TFindDialog, how do I get the cursor is in the edit box without clicking in the edit box. I know FindText will put text in the box but I want the cursor there too.
Dennis_TreacyAsked:
Who is Participating?
 
Ephraim WangoyaCommented:

I'm not sure I understand but, whenever you call FindDialog.Execute, the cursor will be placed in the FinDialog Edit box unless you are specifically moving the focus somewhere else

  FindDialog1.FindText := 'Memo';
  FindDialog1.Execute(Self.Handle);
After this code, focus is on the edit box of finddialog

On the other hand, if you change the focus, then the edit box looses the focus
  FindDialog1.FindText := 'Memo';
  FindDialog1.Execute(Self.Handle);
  Memo1.SetFocus;
Now the focus is on Memo1
0
 
jimyXCommented:
Use:
Edit1.Setfocus;
0
 
fromerCommented:
I think Dennis_Treacy is talking about the EditBox in the TFindDialog...
I looked at the components[] property, but it counts 0...

TFindDialog calls the function from
function FindText; external commdlg32  name 'FindTextA';

As

FFindHandle := FFindReplaceFunc(FFindReplace);

So we have to look at the child windows of FFindHandle, But it's private :)..

An ugly approach:
  Copy all the codes of TFindDialog to a new unit,

Then, by the help of FindWindowEx function acquire the handle of EditBox,
Finally call the function Windows.SetFocus(HandleOfEditBox);

However, If i execute the FindDialog, The focus is on EditBox..


 





 




0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fromerCommented:
Ugly approach became very ugly when i tried :)..
Have to copy half of the unit Dialogs...So let's forget it...
0
 
Geert GOracle dbaCommented:
if you run like this the edit box in the find dialog will be focused

FindDialog1.Execute(Edit1.Handle);
0
 
Dennis_TreacyAuthor Commented:
Edit1 is an undeclared identifier. Is there an actual published name for that edit box component?
0
 
Dennis_TreacyAuthor Commented:
FindDialog1.Execute(self.Handle) is the answer;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.