在函数bool createview( int row, int col, cruntimeclass* pviewclass, size sizeinit, ccreatecontext* pcontext );
中,有一个参数ccreatecontext* pcontext,里面有当前的document的指针
而在cview的oncreate中:
// if ok, wire in the current document
assert(m_pdocument == null);
ccreatecontext* pcontext = (ccreatecontext*)lpcs->lpcreateparams;
// a view should be created in a given context!
if (pcontext != null && pcontext->m_pcurrentdoc != null)
{
pcontext->m_pcurrentdoc->addview(this);
assert(m_pdocument != null);
}
就是在这里调用addview的。
ok,that's it.