Template 상속받는 UI클래스 구현
어디선가 긁어 와서 메모 해두었던 자료인데 출처가 기억 나지 않는다.
// template용 메시지 맵
#pragma once
#if _MFC_VER >= 0x0600 && _MFC_VER < 0x0700
// MFC for Visual C++ 6.0 (MFC 4.x)
#ifdef _AFXDLL
#define BEGIN_MESSAGE_MAP_TEMPLATE(templateList, templateClass, theClass, baseClass) \
templateList const AFX_MSGMAP* PASCAL templateClass::_GetBaseMessageMap() \
{ return &baseClass::messageMap; } \
templateList const AFX_MSGMAP* templateClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
templateList AFX_COMDAT AFX_DATADEF const AFX_MSGMAP templateClass::messageMap = \
{ &theClass::_GetBaseMessageMap, &theClass::_messageEntries[0] }; \
templateList AFX_COMDAT const AFX_MSGMAP_ENTRY templateClass::_messageEntries[] = \
{ \
#else
#define BEGIN_MESSAGE_MAP_TEMPLATE(templateList, templateClass, theClass, baseClass) \
templateList const AFX_MSGMAP* templateClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
templateList AFX_COMDAT AFX_DATADEF const AFX_MSGMAP templateClass::messageMap = \
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \
templateList AFX_COMDAT const AFX_MSGMAP_ENTRY templateClass::_messageEntries[] = \
{ \
#endif
#elif _MFC_VER >= 0x0700 && _MFC_VER < 0x0800
// MFC for Visual C++ 7.0 (MFC 7.x)
#ifdef _AFXDLL
#define BEGIN_MESSAGE_MAP_TEMPLATE(templateList, templateClass, theClass, baseClass) \
templateList const AFX_MSGMAP* PASCAL templateClass::GetThisMessageMap() \
{ return &theClass::messageMap; } \
templateList const AFX_MSGMAP* templateClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
templateList /*AFX_COMDAT*/ const AFX_MSGMAP templateClass::messageMap = \
{ &baseClass::GetThisMessageMap, &theClass::_messageEntries[0] }; \
templateList /*AFX_COMDAT*/ const AFX_MSGMAP_ENTRY templateClass::_messageEntries[] = \
{ \
#else
#define BEGIN_MESSAGE_MAP_TEMPLATE(templateList, templateClass, theClass, baseClass) \
templateList const AFX_MSGMAP* templateClass::GetMessageMap() const \
{ return &theClass::messageMap; } \
templateList /*AFX_COMDAT*/ const AFX_MSGMAP templateClass::messageMap = \
{ &baseClass::messageMap, &theClass::_messageEntries[0] }; \
templateList /*AFX_COMDAT*/ const AFX_MSGMAP_ENTRY templateClass::_messageEntries[] = \
{ \
#endif
// 헤더
template <class BASE= CDialog> class CMyDialog : public BASE
{
};
// cpp
#if 1
// define this to use that source file as template
#define TEMPLATE template <class BASE>
#else
// define this to instantiate functions for class 'BASE' right in this CPP module
#define TEMPLATE
#define BASE CMyDialog
#endif
BEGIN_MESSAGE_MAP_TEMPLATE(TEMPLATE, CMyDialog <BASE>, CMyDialog, BASE)
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
END_MESSAGE_MAP()
// 구현..
TEMPLATE BOOL CMyDialog<BASE>::OnInitDialog()
{
BOOL bReturn= BASE::OnInitDialog();
return bReturn;
}
'개발언어 > c++' 카테고리의 다른 글
Cedit버디컨트롤 (0) | 2016.06.13 |
---|---|
Object instantiation / Template / Reference (0) | 2016.06.13 |
switch case 에 문자열 사용하기 (0) | 2016.06.13 |
웹에서 다운로드 (0) | 2016.06.13 |
클래스 템플릿 (0) | 2016.06.13 |