CCheckListBox的示例 http://www.codeproject.com/combobox/CCheckListBoxUsage.aspSubclassWindow的示例:你自己到MSDN里面有~~~ // The following code shows how to subclass the edit control and list box // controls inside a combo box. It uses WM_CTLCOLOR for subclassing. // CSuperComboBox represents the combo box. HBRUSH CSuperComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { if (nCtlColor == CTLCOLOR_EDIT) { //Edit control if (m_edit.GetSafeHwnd() == NULL) m_edit.SubclassWindow(pWnd->GetSafeHwnd()); } else if (nCtlColor == CTLCOLOR_LISTBOX) { //ListBox control if (m_listbox.GetSafeHwnd() == NULL) m_listbox.SubclassWindow(pWnd->GetSafeHwnd()); } HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor); return hbr; }void CSuperComboBox::OnDestroy() { // Unsubclass both edit and list box before destruction. if (m_edit.GetSafeHwnd() != NULL) m_edit.UnsubclassWindow(); if (m_listbox.GetSafeHwnd() != NULL) m_listbox.UnsubclassWindow(); CComboBox::OnDestroy(); }
http://www.codeproject.com/combobox/CCheckListBoxUsage.aspSubclassWindow的示例:你自己到MSDN里面有~~~
// The following code shows how to subclass the edit control and list box
// controls inside a combo box. It uses WM_CTLCOLOR for subclassing.
// CSuperComboBox represents the combo box.
HBRUSH CSuperComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)
{
//Edit control
if (m_edit.GetSafeHwnd() == NULL)
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
}
else if (nCtlColor == CTLCOLOR_LISTBOX)
{
//ListBox control
if (m_listbox.GetSafeHwnd() == NULL)
m_listbox.SubclassWindow(pWnd->GetSafeHwnd());
}
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}void CSuperComboBox::OnDestroy()
{
// Unsubclass both edit and list box before destruction.
if (m_edit.GetSafeHwnd() != NULL)
m_edit.UnsubclassWindow();
if (m_listbox.GetSafeHwnd() != NULL)
m_listbox.UnsubclassWindow();
CComboBox::OnDestroy();
}
void CSuperEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(nChar==VK_RETURN)
{
MessageBox("aaaaaaaaaaaa");
}
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
按return仍然不行