Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding views to the view list of a document

Status
Not open for further replies.

pdunncs

Technical User
Jun 21, 2003
12
0
0
US
I need help with adding a view(s) to the document view list.
I know that CDocument::AddView() will add the view to the view list. The CView::OnCreate() is suppose to call the AddView(), but I don't have an OnCreate, I have Create() in my SecondView class. My FirstView does get adding to the view list. There is a difference in my second view (SecondView) than in my first view (FirstView). FirstView uses a PreCreateWindow(cs) method and my SecondView uses a Create(...) method. In the PreCreateWindow(cs) method, CListView::preCreateWindow(cs) is called. In my Create method the first few lines of code is

if (!CWnd::Create(lpszClassName, lpszWindowName, dwStyle | WS_CLIPCHILDREN,
rect, pParentWnd, nID, pContext))
{
return FALSE;
}

it does not call the base class CFormView::Create(...), I have tried that and got an error.

In my CWinApp derived class I have the method
LoadFrames(){
m_pSecondView->OpenDocumentFile(NULL);
m_pFirstView->OpenDocumentFile(NULL);
}

m_pSecondView and m_pFirstView are CMultiDocTemplate* type.

When I use the following in another method in my CWinApp derived class
pos = m_pSecondView->GetFirstDocPosition();
pDoc = m_pSeconView->GetNextDoc(pos);
pDoc will equal the correct class (CMyDoc)

However, in my CMyDoc file

pos = pDoc->GetFirstViewPosition();
CView* prog;
while(pos != NULL)
{
prog = pDoc->GetNextView(pos);
if(prog->IsKindOf(RUNTIME_CLASS(CSecondView)))
((CSecondView*)prog)->Method(m_nVar);
}

The only view prog ever get populated with is CFirstView.
Also in my CWinApp derived class, I use the line
CDocument* pDoc = pChild->GetActiveDocument();
and found out (when pChild = CSecondFrame [see next paragraph]) pDoc will be set to NULL 0x000000.

If it is important I have defined the CMultiDocTemplate pointers as such
m_pFirstView = new CMultiDocTemplate(IDR_FIRSTTYPE,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CFirstView));
AddDocTemplate(m_pFirstView);

m_pSecondView = new CMultiDocTemplate(IDR_SECONDTYPE,
RUNTIME_CLASS(CMYDoc),
RUNTIME_CLASS(CSecondFrame),
RUNTIME_CLASS(CSecondView));
AddDocTemplate(m_pSecondView);

as you will notice, two different frames and IDRs are used. I don't believe that should make a difference in regards to the CMyDoc class, but I am writing all that could be revelant.

The information that I need is, how do I get my SecondView associated in the view list of my MyDoc class.

Thank you for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top