积极答复者
MFC 控件 “模板”+“派生”类的创建方法

问题
-
我
我想要创建一个ListBox的派生类,并且采用模板,代码大致意思如下
in H File
template <class Type,...Args>
class CExListBox : public CListBox
{
DECLARE_DYNAMIC(CExListBox)
public:
CExListBox();
virtual ~CExListBox();
protected:
DECLARE_MESSAGE_MAP()...... some function in class
}
in CPP File
IMPLEMENT_DYNAMIC(CExListBox, CListBox)
template <class Type, class...Args>
CExListBox<Type,...Args>::CExListBox()
{
}
template <class Type, class...Args>
CExListBox<Type,...Args>::~CExListBox()
{
}
BEGIN_MESSAGE_MAP(CExListBox<Typem,...Args>, CListBox)
END_MESSAGE_MAP()
........some function in class
有人能否帮我看一下
DECLARE_DYNAMIC(CExListBox)
IMPLEMENT_DYNAMIC(CExListBox, CListBox)
BEGIN_MESSAGE_MAP(CExListBox<Typem,...Args>, CListBox)
and
END_MESSAGE_MAP()
这几个宏到底应该怎么写,我怎么写都会编译报错,还有其他的地方我有没有写错的
双手抱拳感谢。。。
答案
-
参考这个文章: http://www.codeproject.com/Articles/351/Templates-and-MFC
可能类似这样的形式:
BEGIN_TEMPLATE_MESSAGE_MAP(<class T>, TListBox<T>, CJBListBox) ON_WM_DESTROY() END_MESSAGE_MAP()
还有这个MSDN 的sample
https://msdn.microsoft.com/en-us/library/aa986916.aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.
全部回复
-
参考这个文章: http://www.codeproject.com/Articles/351/Templates-and-MFC
可能类似这样的形式:
BEGIN_TEMPLATE_MESSAGE_MAP(<class T>, TListBox<T>, CJBListBox) ON_WM_DESTROY() END_MESSAGE_MAP()
还有这个MSDN 的sample
https://msdn.microsoft.com/en-us/library/aa986916.aspx
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.