Solved

Create View "dynamically"! Helpppp

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 116
ShiftLeft challenge 21 95
MaxSpan challenge 9 139
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,686
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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