读书人

动态创建的视怎么连接文档

发布时间: 2012-04-01 17:23:46 作者: rapoo

动态创建的视如何连接文档?
我的代码如下:
pCodeView = (CCodeEditView*)RUNTIME_CLASS(CCodeEditView)->CreateObject();

CCreateContext contextT;
contextT.m_pNewViewClass = (CRuntimeClass*)pCodeView;

CWnd* pWnd;
TRY
{
pWnd = (CWnd*)pCodeView;
if (pWnd == NULL)
{
AfxThrowMemoryException();
}
}
CATCH_ALL(e)
{
TRACE0( "Out of memory creating a view.\n" );
return FALSE;
}
END_CATCH_ALL

DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
dwStyle &= ~WS_BORDER;

if (!pWnd->Create(NULL, NULL, dwStyle,
CRect(0,0,0,0), this, (AFX_IDW_PANE_FIRST), &contextT))
{
TRACE0( "Warning: couldn't create client tab for view.\n" );
return FALSE;
}

pWnd->SetOwner(this);
现在想给些视连接文档,如何实现。

[解决办法]

C/C++ code
CFrameWnd* pFrame = new CFrameWnd;    CCreateContext cc;    cc.m_pCurrentDoc = (CDocument*)RUNTIME_CLASS(CNewDoc)->CreateObject();    cc.m_pNewViewClass = RUNTIME_CLASS(CNewView);    cc.m_pCurrentFrame = pFrame;    pFrame->Create(NULL, _T("MyFrameWnd"), WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, NULL, NULL, 0, &cc);    pFrame->ShowWindow(SW_SHOW); 

读书人网 >VC/MFC

热点推荐