Link to home
Start Free TrialLog in
Avatar of Dennis_Treacy
Dennis_TreacyFlag for Australia

asked on

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.
Avatar of jimyX
jimyX

Use:
Edit1.Setfocus;
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..


 





 




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

FindDialog1.Execute(Edit1.Handle);
Avatar of Dennis_Treacy

ASKER

Edit1 is an undeclared identifier. Is there an actual published name for that edit box component?
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FindDialog1.Execute(self.Handle) is the answer;