Select the product you need help with
How to subclass CListBox and CEdit inside of CComboBoxArticle ID: 174667 - View products that this article applies to. This article was previously published under Q174667 On This PageSUMMARY
While it is simple to directly subclass a combo box control, it is not
simple to subclass the edit or list box inside a combo box. The problem is
that it is difficult to get the HWNDs of the child controls in a portable
manner.
One safe way to subclass the internal edit and list box controls is to subclass them in the WM_CTLCOLORXXX messages. Because Win32 sends separate WM_CTLCOLOREDIT and WM_CTLCOLORLISTBOX messages, these messages are safe and easy ways to get the HWNDs of the child controls of the combo box. Below is a CSuperComboBox class, which is an MFC implementation of this method. Because MFC routes all the WM_CTLCOLOR messages to OnCtlColor, the subclassing takes place there. MORE INFORMATION
Use ClassWizard to derive a class from CComboBox and add message handlers
for WM_CTLCOLOR and WM_DESTROY. Then manually edit the header file to add
the data members, m_edit and m_listbox. Finally, copy the code from the
message handlers below:
Sample code(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Kelly Marie Ward, Microsoft Corporation PropertiesArticle ID: 174667 - Last Review: November 21, 2006 - Revision: 4.1 APPLIES TO
| Article Translations
|


Back to the top








