MFC 消息流程 处理的问题 (中级)
sock5 2006-03-27 04:43:00 原来的程序这样,好使
CMydlg : public CDialog
{
CXTPReportControl m_wndReport;
afx_msg void OnReportBeginDrag(NMHDR * pNotifyStruct, LRESULT * result);
...
}
.cpp
BEGIN_MESSAGE_MAP(CMydlg,CDialog)
ON_NOTIFY(LVN_BEGINDRAG, IDC_REPORT, OnReportBeginDrag)
END_MESSAGE_MAP()
这样做可以正常执行这个开始拖拽事件,但是我稍微小改了一下,将事件放到了子控件类中,这个拖拽消息就不好使了,但是鼠标消息别的好使,说明消息循环没问题,但是却不支持这个拖拽事件了,应该怎么样解决?
CMyReportControl : public CXTPReportControl
{
afx_msg void OnReportBeginDrag(NMHDR * pNotifyStruct, LRESULT * result);
DECLARE_DYNAMIC(CMyReportControl) //使该窗口支持动态创建
DECLARE_MESSAGE_MAP() //使该窗口支持消息映射
...
}
CMydlg : public CDialog
{
CMyReportControl m_wndReport;
}
//并将消息循环进行了修改,但是不好使,大家帮忙看看是哪里出现问题了呢,注意一定要说关键的地方
IMPLEMENT_DYNAMIC(CMyReportControl, CXTPReportControl)
IMPLEMENT_DYNAMIC(CMyDlg, CDialog)
BEGIN_MESSAGE_MAP(CMyReportControl, CXTPReportControl)//这里的消息流向必须从父类流向子类,否则控件不正常
ON_NOTIFY(LVN_BEGINDRAG, IDC_REPORT, OnReportBeginDrag) //开始拖拽消息
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
END_MESSAGE_MAP()