开发者

Can't get OnContextMenu to work for custom CListCtl class

开发者 https://www.devze.com 2022-12-19 01:29 出处:网络
I am trying to get a context menu to work for a CListCtrl derived class.I just created a method OnContextMenu, but it isn\'t being called.What am I missing?I am using Visual Studio 2008, to create a C

I am trying to get a context menu to work for a CListCtrl derived class. I just created a method OnContextMenu, but it isn't being called. What am I missing? I am using Visual Studio 2008, to create a CDialog based MFC application.

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");
}


I found out I had to add ON_WM_CONTEXTMENU() to message map.

0

精彩评论

暂无评论...
验证码 换一张
取 消