【发布时间】:2010-02-05 13:49:16
【问题描述】:
我正在尝试使上下文菜单适用于 CListCtrl 派生类。我刚刚创建了一个方法 OnContextMenu,但它没有被调用。我错过了什么?我正在使用 Visual Studio 2008 创建一个基于 CDialog 的 MFC 应用程序。
自定义列表.h
class tcCustomListCtl : public CListCtl
{
DECLARE_DYNAMIC(tcCustomListCtl)
public:
tcCustomListCtl();
virtual ~tcCustomListCtl();
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnContextMenu(CWnd* pWnd,CPoint pos );
};
自定义列表.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");
}
【问题讨论】:
标签: mfc contextmenu clistctrl