Click here to Skip to main content
Click here to Skip to main content

Auto Completion ComboBox for WTL

By , 17 Aug 2003
Rate this:
Please Sign up or sign in to vote.
<!-- Article image -->

Sample Image - wtlautocompletecombo.jpg

<!-- Add the rest of your HTML here -->

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

About the Author

NormDroid
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
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 4 Pinmemberzighouse21-May-12 18:29 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 18 Aug 2003
Article Copyright 2003 by NormDroid
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid