?
Solved

Setfocus in edit box of TFindDialog

Posted on 2011-05-05
7
Medium Priority
?
700 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:Dennis_Treacy
7 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35696523
Use:
Edit1.Setfocus;
0
 
LVL 4

Expert Comment

by:fromer
ID: 35696612
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
 
LVL 4

Expert Comment

by:fromer
ID: 35696651
Ugly approach became very ugly when i tried :)..
Have to copy half of the unit Dialogs...So let's forget it...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 35698748
if you run like this the edit box in the find dialog will be focused

FindDialog1.Execute(Edit1.Handle);
0
 

Author Comment

by:Dennis_Treacy
ID: 35703156
Edit1 is an undeclared identifier. Is there an actual published name for that edit box component?
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35703383

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
 

Author Closing Comment

by:Dennis_Treacy
ID: 35703433
FindDialog1.Execute(self.Handle) is the answer;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question