?
Solved

multi-view in an sdi

Posted on 1997-11-19
5
Medium Priority
?
453 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 300 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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

770 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