Home > Windows API > Enable auto completion to your text box, just like Start->Run

Enable auto completion to your text box, just like Start->Run

Use ShAutoComplete.

Goto Start->Run

Type C:\…..

You will get a dropdown list box with all the files and folders in C: drive.

Have you ever thought about incorporating this kind of a behavior into your application…

There is an API which does this… ( Microsoft was generous enough to create one and share it ). 🙂

The API is SHAutoComplete.

All you should have is an edit box. Get the handle to the edit box and pass it to this function. You will get a drop down list box for the path that you are typing in the edit box.
Cool isn’t it. 🙂

For eg:

CoInitialize( 0 );
SHAutoComplete( GetSafeHwnd(), SHACF_DEFAULT );
CoUninitialize();

That’s it now you have autocompletion enabled for your text box/combo box.

NOTE: Don’t forget to call CoInitialize before using this function and of course CoUninitialize. Do look up this API in MSDN. You will find interesting options.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: