How can I change the textbox (Edit) in a Find dialog to a Combobox in Delphi?

312 views Asked by At

I currently use a standard TFindDialog in my Delphi application:

default Find dialog

How can I change the textbox to a combobox? I'd like to set it up so that the user can easily see and select from the history, like this:

mockup of Find dialog with combobox

1

There are 1 answers

0
Remy Lebeau On BEST ANSWER

I currently use a standard FindDialog in my Delphi application.

How can I change the text box to a combo box?

You can't, at least not with TFindDialog, as it does not allow the use of a custom dialog template (the underlying FindText() API does, though).

However, there is another workaround for your situation...

In the TFindDialog.OnShow event, use FindWindowEx() to manually find the HWND of the Edit field in the dialog, and then use the Shell's IAutoComplete interface to enable a drop-down list on that HWND. You can write a class that implements the IEnumString interface to provide the entries that you want to appear in that drop-down list (for instance, by wrapping a TStringList that you store your entries in).

See MSDN documentation for more details:

Using Autocomplete

How to Enable Autocomplete Manually

Also see:

This answer to Google like edit/combo control for Delphi?

This answer to Auto append/complete from text file to an edit box delphi

This answer to How to use IAutoComplete together with TStringsAdapter?