Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multiple views per document

20 views
Skip to first unread message

Paul Schouten

unread,
Jul 14, 2005, 7:15:11 AM7/14/05
to
Hey,

I want to develop a MDI-application with one view (CFormView) on startup.
After user input I would like to open another view derived from CView
presenting the user with the results from his query. In this view the the
user can open each individual item. This should result in another view
derived from CFormView (but ofcourse not the same as the first view visible
on startup) displaying detailed information about the selected item.

I'm pretty new to this doc/view and the whole frame thing. Could someone
tell me how I can get multiple views (all different classes and derived from
2 types of base classes (CView/CFormView))?

cheers,

Paul


AliR

unread,
Jul 14, 2005, 11:40:34 AM7/14/05
to
What you need is different CMultiDocTemplate object for each pair of
documents and views that could be created.
Then when you want to create another view with the same document, use one of
the templates.

void CMyFormView::OnNewView()
{
AfxGetApp()->m_pView1DocTemplate->AddDocument(GetDocument());
CFrameWnd* FrameWnd =
AfxGetApp()->m_pView1DocTemplate->CreateNewFrame(pDoc,NULL);

if (FrameWnd)
{
pDoc->SetTitle(Title);
FrameWnd->SetTitle(Title);

FrameWnd->InitialUpdateFrame(pDoc,TRUE);
FrameWnd->SetFocus();
}
}

or you can do if from the document class, where ever it might make sense to
you.

AliR.

"Paul Schouten" <vincent_...@yahoo.com> wrote in message
news:42d6493f$0$34146$e4fe...@news.xs4all.nl...

Paul Schouten

unread,
Jul 14, 2005, 2:21:40 PM7/14/05
to
Thanks mate!

"AliR" <Al...@online.nospam> schreef in bericht
news:42d68797$1...@alt.athenanews.com...

RainMan

unread,
Aug 3, 2005, 11:27:09 PM8/3/05
to
Depending what you want to do, you may not need another template. From you
description it seems like you really would not want one.
Multiplle templates cause dialog box to come up asking user what kind of
document to open. Each template will create new document object if you use
code from previous post. I think that is behavior you would not want.

You can create any number of views (I think limit is 127) in the same frame
wired to the same document object; hence they all will share the same data.

See this thread: http://www.codeguru.com/forum/showthread.php?t=296513 where
you will fins couple of samples I have posted dealing with different
requirements for using multiple views.

--
RainMan

Paul Schouten

unread,
Aug 7, 2005, 9:21:04 AM8/7/05
to
thanks for your suggestions on how I can tackle this problem!

cheers,

Paul

"RainMan" <Rai...@online.nospam> schreef in bericht
news:98C7BEB5-315C-4118...@microsoft.com...

0 new messages