Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#148: To enable autocomplete for edit/combobox

Starting from IE 5.5 Microsoft added a very cool feature to any editboxes/comboboxes - you may start to enter some value and automatically will be suggested a value from "list" (previous typed)

As you understand now I'll describe how to add such possibility to any editbox from your application:-)

1. you must declare a few const values:
const
SHACF_AUTOSUGGEST_FORCE_ON = $10000000;
SHACF_AUTOSUGGEST_FORCE_OFF = $20000000;
SHACF_AUTOAPPEND_FORCE_ON = $40000000;
SHACF_AUTOAPPEND_FORCE_OFF = $80000000;
SHACF_DEFAULT = $0;
SHACF_FILESYSTEM = $1;
SHACF_URLHISTORY = $2;
SHACF_URLMRU = $4;

2. you must declare a SHAutoComplete function from Shlwapi.dll library:
function SHAutoComplete(hwndEdit: HWnd; dwFlags: DWORD): HResult; stdcall; external 'Shlwapi.dll';

3. now you're ready to add an autosuggestion to your editbox:

var
  Options: dWord;
begin
  Options := SHACF_FILESYSTEM or SHACF_URLHISTORY or SHACF_URLMRU or
              SHACF_AUTOSUGGEST_FORCE_ON or SHACF_AUTOAPPEND_FORCE_ON;
  SHAutoComplete(yourEditBox.Handle, Options);
end;

Of course, you may remove some flags from Options parameter. For example, if you'll exclude the SHACF_URLHISTORY flag, end-user will not see the history of visited URLs

NOTE:
if your application must work in any environment (not only with IE 5.5+), then better to load Shlwapi.dll library dinamically but not link as I shown in this tip. You may read a tip#130 where I described how to work with dll's: Article# 130


Published: December 24, 2003

See also
 
SMDBGrid
DBISAM Viewer
Clarion Viewer
Fast Document Viewer
MAPIMail
Viewer for MS Outlook Messages
SMExport suite
Paradox Viewer
DBExport tools
Paradox Password Recovery
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising