Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / WTL
Article

Auto Completion ComboBox for WTL

Rate me:
Please Sign up or sign in to vote.
3.18/5 (18 votes)
17 Aug 20031 min read 52.4K   2.5K   21   2
Implementation of Auto Completion ComboBox for WTL

Sample Image - wtlautocompletecombo.jpg

Introduction

This article assumes the reader has a basic understanding of C++, Win32 Programming and WTL.

This is an implementation auto completion ComboBox for WTL. This is actually a port of an MFC version found here which Chris Maunder developed.

Background

There's not much to say about an auto completion ComboBox, except that the combo style usually includes CBS_DROPDOWN. It's up to the developer to serialize the contents of the ComboBox (which means loading/saving to a registry, file or database). To help you implement the auto completion dialog in your projects I have labeled code lines that are needed with // _AC_INSERT_ comments.

Using the code

Using the code in your project is pretty simple, the first the step is to edit the header file of your dialog or window class and include the line #include "AutoCombo.h".

The next step is to insert the line CAutoCombo m_cboAuto; as a member variable of your dialog or window class.

To ensure combo messages are handled in the inherited auto completion combo class we must reflect any notifications to other controls, see the following code snippet.

... Some other code
BEGIN_MSG_MAP(CMainDlg)
    MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
    COMMAND_ID_HANDLER(IDOK, OnOK)
    COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
    REFLECT_NOTIFICATIONS() 
END_MSG_MAP()     
... Some other code

One thing to note here is if there are any ATL_ message macros, the REFLECT_NOTIFICATIONS() must be at the beginning of ATL_ message macros.

Finally subclass the combo control by adding the following line when the dialog box is initialised or the window is created (usually handled  in a WM_INITDIALOG handler or WM_CREATE handler.

History

V1.0 Article creation.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) Software Kinetics
United Kingdom United Kingdom




Software Kinetics
are experts in developing customised and bespoke applications and have expertise in the development of desktop, mobile and internet applications on Windows.


We specialise in:

  • User Interface Design
  • Desktop Development
  • Windows Phone Development
  • Windows Presentation Framework
  • Windows Forms
  • Windows Communication Framework
  • Windows Services
  • Network Applications
  • Database Applications
  • Web Development
  • Web Services
  • Silverlight
  • ASP.net


Visit Software Kinetics

Comments and Discussions

 
GeneralMy vote of 4 Pin
zighouse21-May-12 18:29
zighouse21-May-12 18:29 
GeneralPreTranslateMessage Pin
berupon6-May-06 5:06
berupon6-May-06 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.