Adding AutoComplete to your edit controls

For whatever reason, most of the toy applications I tend to write seem to end up being dialog based applications.  I'm not 100% sure why, it probably has to do with the fact that the dialog box editor makes it really easy to drop controls on a page.

 

One of the things I often have to do is to specify a filename to the toy application.  To do that, I usually add an edit control to display the filename and a "Browse..." button which brings up the common file browser control.  Many people find it awkward to use the common file browser to locate files, so they often try typing into the edit control.

One of the really easy "nice touches" that you can specify to help with navigation is to add autocompletion support to the edit control.  Fortunately, the Windows shell provides a really handy mechanism to do this in the SHAutoComplete function. 

Adding autocomplete support is literally as easy as adding:

SHAutoComplete(hWndEdit, SHACF_FILESYSTEM);\

to your code.

It turns out that the shell has a fairly extensive autocomplete mechanism that allows you to customize this facility to a great deal (you can provide your own lists of elements, merge lists from multiple sources, etc).

 

For me, I almost always end up falling back to the old standby of SHAutoComplete - it's trivial to add it, and it adds a nice touch to your applications.