Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create View "dynamically"! Helpppp

Posted on 2003-12-09
2
Medium Priority
?
369 Views
Last Modified: 2013-11-20
I've created a SDI MFC application, with a CSplitterWnd, on the left is a tree view, and the view on right depends on the selected item of the tree view on the left, i don't know how to switch between views.
For example :
If I select an item called "A Item", a "A view" will appear on the right, if  I select an item called "B Item", a "B view" will appear on the right.....
I've read the "SwSplit" (an example about switch between views from a smart guy of Microsoft), but it's over my head!
Are there any simple ways to achieve this!
Thankx
0
Comment
Question by:tinh911
2 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1500 total points
ID: 9902867
CSplitterWnd::DeleteView
virtual void DeleteView( int row, int col );

followed by

CSplitterWnd::CreateView
virtual BOOL CreateView( int row, int col, CRuntimeClass* pViewClass, SIZE sizeInit, CCreateContext* pContext );


for the CreateContext
     // Initialize a CCreateContext to point to the active document.
      // With this context, the new view is added to the document
      // when the view is created in CView::OnCreate().
      CCreateContext newContext;
      newContext.m_pNewViewClass = NULL;
      newContext.m_pNewDocTemplate = NULL;
      newContext.m_pLastView = NULL;
      newContext.m_pCurrentFrame = NULL;
      newContext.m_pCurrentDoc = pCurrentDoc;

      // The ID of the initial active view is AFX_IDW_PANE_FIRST.
      // Incrementing this value by one for additional views works
      // in the standard document/view case but the technique cannot
      // be extended for the CSplitterWnd case.
      UINT viewID = AFX_IDW_PANE_FIRST + 1;
      CRect rect(0, 0, 0, 0); // gets resized later

      // Create the new view. In this example, the view persists for
      // the life of the application. The application automatically
      // deletes the view when the application is closed.
      m_pNewView->Create(NULL, "AnyWindowName", WS_CHILD, rect,
                              m_pMainWnd, viewID, &newContext);

      // When a document template creates a view, the WM_INITIALUPDATE
      // message is sent automatically. However, this code must
      // explicitly send the message, as follows.
      m_pNewView->SendMessage(WM_INITIALUPDATE, 0, 0);
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 9902892
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

824 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