Solved

multi-view in an sdi

Posted on 1997-11-19
5
449 Views
Last Modified: 2010-08-05
I have 4 daorecordviews set up in the init of the app
ex : m_mydoctemp[0] =
CmultiDocTemplate = {menu, doc1, mainframe, view1)
adddoctemp ...
m_mydoctemp[1] =
CmultiDocTemplate = {menu, doc2, mainframe, view2)
adddoctemp ...
the app is designed as a SDI. I want to be able to show different views with there document data when a menu selection is choosen.
Replace one view with the other.  Where do I go from here?
0
Comment
Question by:sas110397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1173632
Basically, you will need to write a function in the mainframe to do this:

 CMainFrame::SwitchToView(int view)
 {
   CView* oldView = GetActiveView();
   CView* newView = NULL;
   switch (view)
   {
     case view1:
       newView = new CView1;
       break;
     case view2:
       newView = new CView2;
       break;
   }

   CCreateContext context;

   // Set up document. This assumes current doc. But if you have
   // new document, then you can create it here
   context.m_pCurrentDoc = pOldView->GetDocument();
   newView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, this, view, &context);
   newView->OnInitialUpdate();
   SetActiveView(newView);
   newView->ShowWindow(SW_SHOW);
   oldView->ShowWindow(SW_HIDE);
   RecalcLayout();
 }
0
 

Author Comment

by:sas110397
ID: 1173633
I think this the right way to go.  However, I tried this last night and Kept recieving an access violation when trying to Create.  I did change the templates back to CSingleDocTemplate,  the Frame is based on CFrameWin.  I had to change the menu resorce in three of the templates to force the NEW window to stop displaying on startup.  I tried changing the sting resource to achieve this but could not get it to start with the first template.  The views and documents I'm trying to create and open are based off of the DAO database classes.
0
 

Expert Comment

by:sreejesh
ID: 1173634
Dear thui, You had given a very good explanation for SDI.But I am asking the same question for MDI.ie., How can I associate a each document to each view (One document for one view). I Expect the very best answer from you !.
0
 

Author Comment

by:sas110397
ID: 1173635
You must make up a document for each view and create a document template for each pair in the init functuion of your app.
Once this is done you can make a call in your program to change the template thus change the view and document pointer.  I don't have the exact code with me right now.  But that's the jist of it.  The templates must be based off of CMultiDocTemplate.
0
 

Expert Comment

by:sreejesh
ID: 1173636
Yes Sas.As you said , I made a document template for the view in the app. But I didn't get which call is to be placed in my program to change the template to change the view and document pointer. Also please let me know where I can call that !.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question