Solved

Create View "dynamically"! Helpppp

Posted on 2003-12-09
2
356 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 44

Accepted Solution

by:
AndyAinscow earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 181
Expand macro to include alternate header placement and naming 5 71
withoutTen challenge 14 121
unix example issues 18 90
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

773 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