Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

C# does Shell, Part 4

, 26 Mar 2003
This article is about the AutoComplete features enabled by windows and how to use them with C#. AutoComplete is the ability to expand strings written in an edit box. The article will develop a class for using this functionality in you applications.
using System;
using System.Runtime.InteropServices;

namespace ShellLib
{
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("00BB2762-6A77-11D0-A535-00C04FD7D062")]
	public interface IAutoComplete 
	{
		/// <summary>
		/// Initializes the autocomplete object.
		/// </summary>
		[PreserveSig]
		Int32 Init(
			IntPtr hwndEdit,						// Handle to the window for the system edit control that is to 
													// have autocompletion enabled. 
			[MarshalAs(UnmanagedType.IUnknown)]
			Object punkACL,							// Pointer to the IUnknown interface of the string list object that 
													// is responsible for generating candidates for the completed 
													// string. The object must expose an IEnumString interface. 
			//IntPtr pwszRegKeyPath,
			[MarshalAs(UnmanagedType.LPWStr)]
			String pwszRegKeyPath,					// Pointer to an optional null-terminated Unicode string that gives
													// the registry path, including the value name, where the format 
													// string is stored as a REG_SZ value. The autocomplete object 
													// first looks for the path under HKEY_CURRENT_USER . If it fails,
													// it then tries HKEY_LOCAL_MACHINE . For a discussion of the 
													// format string, see the definition of pwszQuickComplete. 
			//IntPtr pwszQuickComplete);
			[MarshalAs(UnmanagedType.LPWStr)]
			String pwszQuickComplete);				// Pointer to an optional string that specifies the format to be
													// used if the user enters some text and presses CTRL+ENTER. Set
													// this parameter to NULL to disable quick completion. Otherwise, 
													// the autocomplete object treats pwszQuickComplete as a sprintf 
													// format string, and the text in the edit box as its associated 
													// argument, to produce a new string. For example, set 
													// pwszQuickComplete to "http://www. %s.com/". When a user enters
													// "MyURL" into the edit box and presses CTRL+ENTER, the text in 
													// the edit box is updated to "http://www.MyURL.com/". 

		/// <summary>
		/// Enables or disables autocompletion.
		/// </summary>
		[PreserveSig]
		Int32 Enable(
			Int32 fEnable);							// Value that is set to TRUE to enable autocompletion, or to 
													// FALSE to disable it. 
				
	}
}
	

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Arik Poznanski
Software Developer (Senior) Verint
Israel Israel
Arik Poznanski is a senior software developer at Verint. He completed two B.Sc. degrees in Mathematics & Computer Science, summa cum laude, from the Technion in Israel.
 
Arik has extensive knowledge and experience in many Microsoft technologies, including .NET with C#, WPF, Silverlight, WinForms, Interop, COM/ATL programming, C++ Win32 programming and reverse engineering (assembly, IL).
Follow on   Twitter   Google+

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 27 Mar 2003
Article Copyright 2003 by Arik Poznanski
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid