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

动态创建的视如何连接文档?
我的代码如下:
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);