Mfc Can';无法使OnContextMenu用于自定义CListCtl类

Mfc Can';无法使OnContextMenu用于自定义CListCtl类,mfc,contextmenu,clistctrl,Mfc,Contextmenu,Clistctrl,我正在尝试为CListCtrl派生类使用上下文菜单。我刚刚在ContextMenu上创建了一个方法,但是没有调用它。我错过了什么?我正在使用VisualStudio2008创建一个基于CDDialog的MFC应用程序 CustomList.h class tcCustomListCtl : public CListCtl { DECLARE_DYNAMIC(tcCustomListCtl) public: tcCustomListCtl(); virtual ~tcCu

我正在尝试为CListCtrl派生类使用上下文菜单。我刚刚在ContextMenu上创建了一个方法,但是没有调用它。我错过了什么?我正在使用VisualStudio2008创建一个基于CDDialog的MFC应用程序

CustomList.h

class tcCustomListCtl : public CListCtl
{
    DECLARE_DYNAMIC(tcCustomListCtl)

public:
    tcCustomListCtl();
    virtual ~tcCustomListCtl();

protected:
    DECLARE_MESSAGE_MAP()

    afx_msg void OnContextMenu(CWnd* pWnd,CPoint pos );
};
CustomList.cpp

// tcFaultListCtl
IMPLEMENT_DYNAMIC(tcCustomListCtl, CListCtrl)

tcCustomListCtl::tcCustomListCtl()
{
}

tcCustomListCtl::~tcCustomListCtl()
{
}

BEGIN_MESSAGE_MAP(tcCustomListCtl, CListCtrl)
END_MESSAGE_MAP()

// tcCustomListCtl message handlers
afx_msg void tcCustomListCtl::OnContextMenu(CWnd* pWnd,CPoint pos )
{
  TRACE("tcCustomListCtl::OnContextMenu\n");
}

我发现我必须在消息映射中添加_WM_CONTEXTMENU()