// 一个RUNTIME_CLASS()应用代码段
// Get run time informations via runtime_class macro
CRuntimeClass * pRTCViewSmall = RUNTIME_CLASS(CTSHEditViewSmall);
#ifdef _DEBUG
ASSERT_VALID(this);
ASSERT(pRTCViewSmall != NULL);
ASSERT(AfxIsValidAddress(pRTCViewSmall,sizeof(CRuntimeClass),FALSE));
ASSERT(pRTCViewSmall->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
#endif
// Create a c++ object dynamicly
CTSHEditViewSmall* pTSHEditViewSmall = NULL;
TRY
{
pTSHEditViewSmall = (CTSHEditViewSmall*) pRTCViewSmall->CreateObject();
if(pTSHEditViewSmall == NULL) AfxThrowMemoryException();
}
CATCH_ALL(e)
{
TIP("Out of memory creating a view .");
return -1;
}
END_CATCH_ALL
// Get run time informations via runtime_class macro
CRuntimeClass * pRTCViewSmall = RUNTIME_CLASS(CTSHEditViewSmall);
#ifdef _DEBUG
ASSERT_VALID(this);
ASSERT(pRTCViewSmall != NULL);
ASSERT(AfxIsValidAddress(pRTCViewSmall,sizeof(CRuntimeClass),FALSE));
ASSERT(pRTCViewSmall->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
#endif
// Create a c++ object dynamicly
CTSHEditViewSmall* pTSHEditViewSmall = NULL;
TRY
{
pTSHEditViewSmall = (CTSHEditViewSmall*) pRTCViewSmall->CreateObject();
if(pTSHEditViewSmall == NULL) AfxThrowMemoryException();
}
CATCH_ALL(e)
{
TIP("Out of memory creating a view .");
return -1;
}
END_CATCH_ALL
解决方案 »
- 完成端口 投递一次后socket就INVALID_SOCKET?
- sql类型?
- 进入MessageBox调试,查看代码;MessageBox的原理是什么
- 谁有WDK for sever 2008的?
- VS2008中的VC是哪个版本....................................
- 文档视图结构如何作类似于Visio的分页显示?
- 一个简单的DirectDraw的问题.
- 关于static的简单问题?
- 两个unresolved external symbol问题
- IOCP中,重用Socket,DisconnectEx阻塞了100多秒
- 如何用CDaoDatabase.. 取ISAM库中图形字段的内容?
- 如何在VC中实现COPY文件?!!
you can send mail to [email protected], if you want
more info.
jansen#define DECLARE_DYNAMIC(class_name) \
protected: \
static CRuntimeClass* PASCAL _GetBaseClass(); \
public: \
static const AFX_DATA CRuntimeClass class##class_name; \
virtual CRuntimeClass* GetRuntimeClass() const; \
#define DECLARE_DYNAMIC(class_name) \
public: \
static const AFX_DATA CRuntimeClass class##class_name; \
virtual CRuntimeClass* GetRuntimeClass() const; \#define IMPLEMENT_DYNAMIC(class_name, base_class_name) \
IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)///////////////////////////////////////
#define DECLARE_DYNCREATE(class_name) \
DECLARE_DYNAMIC(class_name) \
static CObject* PASCAL CreateObject();#define IMPLEMENT_DYNCREATE(class_name, base_class_name) \
CObject* PASCAL class_name::CreateObject() \
{ return new class_name; } \
IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
class_name::CreateObject)///////////////////////////////////////
#define IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \
CRuntimeClass* PASCAL class_name::_GetBaseClass() \
{ return RUNTIME_CLASS(base_class_name); } \
const AFX_DATADEF CRuntimeClass class_name::class##class_name = { \
#class_name, sizeof(class class_name), wSchema, pfnNew, \
&class_name::_GetBaseClass, NULL }; \
CRuntimeClass* class_name::GetRuntimeClass() const \
{ return RUNTIME_CLASS(class_name); } \
#define IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \
const AFX_DATADEF CRuntimeClass class_name::class##class_name = { \
#class_name, sizeof(class class_name), wSchema, pfnNew, \
RUNTIME_CLASS(base_class_name), NULL }; \
CRuntimeClass* class_name::GetRuntimeClass() const \
{ return RUNTIME_CLASS(class_name); } \///////////////////////////////////////
struct CRuntimeClass
{
// Attributes
LPCSTR m_lpszClassName;
int m_nObjectSize;
UINT m_wSchema; // schema number of the loaded class
CObject* (PASCAL* m_pfnCreateObject)(); // NULL => abstract class
#ifdef _AFXDLL
CRuntimeClass* (PASCAL* m_pfnGetBaseClass)();
#else
CRuntimeClass* m_pBaseClass;
#endif// Operations
CObject* CreateObject();
BOOL IsDerivedFrom(const CRuntimeClass* pBaseClass) const;// Implementation
void Store(CArchive& ar) const;
static CRuntimeClass* PASCAL Load(CArchive& ar, UINT* pwSchemaNum); // CRuntimeClass objects linked together in simple list
CRuntimeClass* m_pNextClass; // linked list of registered classes
}