Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiple document interface(MDI)

Posted on 1999-07-15
4
Medium Priority
?
183 Views
Last Modified: 2013-11-20
actually i want to come out with a frame which have 2 views(each view tie to their respective document-b'cos the data shown on one view is different from the others). these views are only shown when the user requests it. however these 2 views are able to keep refreshing(real-time) their content(document data) when they are hidden or showing.
(note : currently i only have one frame with one view one document. And the view are able to data refresh in real-time)
0
Comment
Question by:swtang72
[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
4 Comments
 
LVL 3

Accepted Solution

by:
Shay050799 earned 1000 total points
ID: 1310059
in the mainframe window put menu entries to change the view:


put this in the menu entry when u want to change the view

      long m_nCurrentExample;

/* gets the current view */      
      CView* pOldActiveView = GetActiveView();
            ::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, m_nCurrentExample);

      CRuntimeClass* pNewViewClass;      
      pNewViewClass = RUNTIME_CLASS(CShayView); // here set the new view class

      CCreateContext context;
      context.m_pNewViewClass = pNewViewClass;
      context.m_pCurrentDoc = GetActiveDocument();
/* create the new view and attach it to the mainframe */
      CView* pNewView = STATIC_DOWNCAST(CView, CreateView(&context));
      if (pNewView != NULL)
      {
            // the new view is there, but invisible and not active...
            pNewView->ShowWindow(SW_SHOW);
            pNewView->OnInitialUpdate();
            SetActiveView(pNewView);
            RecalcLayout();            

            // finally destroy the old view...
            pOldActiveView->DestroyWindow();
      }


0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1310060
shay,
there is slight problem in your answer...

1. You have to destroy the old view before you activate the new one. Because when you destroy a view, it sets the Active view of the frame to be NULL.

void CView::OnDestroy()
{
      CFrameWnd* pFrame = GetParentFrame();
      if (pFrame != NULL && pFrame->GetActiveView() == this)
            pFrame->SetActiveView(NULL);    // deactivate during death
      CWnd::OnDestroy();
}

2. When view is being destroyed, DOC/VIEW architecture can delete your document also.
So you have to protect against that when you r destroying view. Set m_bAutoDelete to FALSE before you make destroywindow call and then reinstate the variable state.

Tang... the answer to this question is same as the one you asked before for SDI..


0
 
LVL 3

Expert Comment

by:Shay050799
ID: 1310061
naveenkohli ! thank u very much.
i didn't know that, cause i m using it for SDI, and it works, never tried it for MDI.

thank u
0
 

Author Comment

by:swtang72
ID: 1310062
naveen,
i need to take some time to 'digest' the sample project that u 've given to me. so that i can decide how much point i should reward u. pls be patient.
but anyway the your info is quite sufficient and at the same time ,very fast reponse !!
thank u.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

730 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