VC添加类 10
用MFC类向导没有找到基类CSplitterWnd,手动添加了classCDynSplitterWnd:publicCSplitterWnd,但是在CDynSplitte...
用MFC类向导没有找到基类CSplitterWnd ,手动添加了class CDynSplitterWnd : public CSplitterWnd ,但是在CDynSplitterWnd类上点击右建只有添加成员变量和添加成员函数,少了添加虚函数和消息句柄的选项,该怎么添加?
展开
展开全部
在其中选new
在随后的对话框中输入CMyView
在base Class里选一个基类//可以随便选
CView CEditView都行
cx.m_pNewViewClass=RUNTIME_CLASS(CMyView);
这一句一般是由VC自动生成不需要自己写
//出现在下面这个函数里
CFrameWnd* CDocTemplate::CreateNewFrame(CDocument* pDoc, CFrameWnd* pOther)
{
if (pDoc != NULL)
ASSERT_VALID(pDoc);
// create a frame wired to the specified document
ASSERT(m_nIDResource != 0); // must have a resource ID to load from
CCreateContext context;
context.m_pCurrentFrame = pOther;
context.m_pCurrentDoc = pDoc;
context.m_pNewViewClass = m_pViewClass;
context.m_pNewDocTemplate = this;
if (m_pFrameClass == NULL)
{
TRACE0("Error: you must override CDocTemplate::CreateNewFrame.\n");
ASSERT(FALSE);
return NULL;
}
CFrameWnd* pFrame = (CFrameWnd*)m_pFrameClass->CreateObject();
if (pFrame == NULL)
{
TRACE1("Warning: Dynamic create of frame %hs failed.\n",
m_pFrameClass->m_lpszClassName);
return NULL;
}
ASSERT_KINDOF(CFrameWnd, pFrame);
if (context.m_pNewViewClass == NULL)
TRACE0("Warning: creating frame with no default view.\n");
// create new from resource
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, // default frame styles
NULL, &context))
{
TRACE0("Warning: CDocTemplate couldn't create a frame.\n");
// frame will be deleted in PostNcDestroy cleanup
return NULL;
}
// it worked !
return pFrame;
}
我不知道你要做什么
如果是动态创建的话只要
在.h文件加宏
DECLARE_DYNCREATE(CMyView)
在.cpp加
IMPLEMENT_DYNCREATE(CMyView, CView)
在随后的对话框中输入CMyView
在base Class里选一个基类//可以随便选
CView CEditView都行
cx.m_pNewViewClass=RUNTIME_CLASS(CMyView);
这一句一般是由VC自动生成不需要自己写
//出现在下面这个函数里
CFrameWnd* CDocTemplate::CreateNewFrame(CDocument* pDoc, CFrameWnd* pOther)
{
if (pDoc != NULL)
ASSERT_VALID(pDoc);
// create a frame wired to the specified document
ASSERT(m_nIDResource != 0); // must have a resource ID to load from
CCreateContext context;
context.m_pCurrentFrame = pOther;
context.m_pCurrentDoc = pDoc;
context.m_pNewViewClass = m_pViewClass;
context.m_pNewDocTemplate = this;
if (m_pFrameClass == NULL)
{
TRACE0("Error: you must override CDocTemplate::CreateNewFrame.\n");
ASSERT(FALSE);
return NULL;
}
CFrameWnd* pFrame = (CFrameWnd*)m_pFrameClass->CreateObject();
if (pFrame == NULL)
{
TRACE1("Warning: Dynamic create of frame %hs failed.\n",
m_pFrameClass->m_lpszClassName);
return NULL;
}
ASSERT_KINDOF(CFrameWnd, pFrame);
if (context.m_pNewViewClass == NULL)
TRACE0("Warning: creating frame with no default view.\n");
// create new from resource
if (!pFrame->LoadFrame(m_nIDResource,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, // default frame styles
NULL, &context))
{
TRACE0("Warning: CDocTemplate couldn't create a frame.\n");
// frame will be deleted in PostNcDestroy cleanup
return NULL;
}
// it worked !
return pFrame;
}
我不知道你要做什么
如果是动态创建的话只要
在.h文件加宏
DECLARE_DYNCREATE(CMyView)
在.cpp加
IMPLEMENT_DYNCREATE(CMyView, CView)
追问
我想新建一个类,基类是CSplitterWnd ,但如果类的类型是MFC Class,base Class中没有CSplitterWnd;如果Generic Class类型的话,新建的类中不能添加虚函数和消息句柄。我想添加虚函数和消息句柄,怎么办?谢谢了……
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询