我希望实现一个可以编辑的CListCtrl,所以我首先从CEdit继承了一个类CEditEx,EditEx.h:#if !defined(AFX_EDITEX_H__DD1E8E8F_1154_4540_9EEA_05DA429306BA__INCLUDED_)
#define AFX_EDITEX_H__DD1E8E8F_1154_4540_9EEA_05DA429306BA__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// EditEx.h : header file
//#include "ListCtrlEx.h"/////////////////////////////////////////////////////////////////////////////
// CEditEx windowclass CEditEx : public CEdit
{
// Construction
public:
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEditEx)
public:
//}}AFX_VIRTUAL// Implementation
public:
CEditEx( CListCtrlEx* pParent, long nItem, long nSubItem, CString& strInit );
virtual ~CEditEx(); // Generated message map functions
protected:
//{{AFX_MSG(CEditEx)
afx_msg void OnNcDestroy();
afx_msg void OnKillFocus(CWnd* pNewWnd);
//}}AFX_MSG
void DealDestory(); //Send Message to ListCtrlEx about the modify
CEditEx() {} // should not be use// Attribute
protected:
long m_nItem;
long m_nSubItem;
CListCtrlEx* m_pParent;
CString m_strInit;
BOOL m_bEscape;protected:
DECLARE_MESSAGE_MAP()
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_EDITEX_H__DD1E8E8F_1154_4540_9EEA_05DA429306BA__INCLUDED_)
EditEx.cpp// EditEx.cpp : implementation file
//#include "stdafx.h"
#include "MultifunctionList.h"
#include "EditEx.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CEditEx
CEditEx::CEditEx(CListCtrlEx *pParent, long nItem, long nSubItem, CString& strInit)
{
ASSERT( NULL != pParent );
m_pParent = pParent;
m_nItem = nItem;
m_nSubItem = nSubItem;
m_strInit =strInit;
m_bEscape = FALSE;
}CEditEx::~CEditEx()
{
}
BEGIN_MESSAGE_MAP(CEditEx, CEdit)
//{{AFX_MSG_MAP(CEditEx)
ON_WM_NCDESTROY()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CEditEx message handlersvoid CEditEx::OnNcDestroy() 
{
CEdit::OnNcDestroy();

// TODO: Add your message handler code here
delete this;
}void CEditEx::OnKillFocus(CWnd* pNewWnd) 
{
CEdit::OnKillFocus(pNewWnd);

// TODO: Add your message handler code here
DealDestory(); CEdit::DestroyWindow();
}void CEditEx::DealDestory()
{}可是我的这个类并不会响应OnKillFocus这个函数,为什么啊?