0

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

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
lkessler
  • 19,819
  • 36
  • 132
  • 203
  • 1
    I always create my own find dialogs/panels. The Win32 one looks a bit dated. It's not hard to make a better one. – Andreas Rejbrand Jul 06 '22 at 00:07
  • Same here, because I also always want to provide at least "regular expressions" as option and "count all" as button. Using a Combobox instead of an Edit for the text to provide an MRU list is a secondary feature I add (including the possibility to delete single entries thru the `Delete` key again when the list is displayed and one item selected). – AmigoJack Jul 06 '22 at 08:47

1 Answers1

4

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?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770