Solved

Create View "dynamically"! Helpppp

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 56
only14 challenge 19 64
Window placement 17 65
zeroFront challenge 7 71
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now