Different Views In Dynamic Splitter

Same view in the dynamic splitter is very restrictive. There is no point in creating same type of views. Here is a way to create different view, each time you split the window.

In class definition of CSplitterWnd, there is a protected member m_pDynamicViewClass of the type CRunTimeClass *. This member is initialized in the Create call of the splitter window. Next time when a view is created, new view is constructed using m_pDynamicViewClass member. To get a different view, you will just have to change the member m_pDynamicViewClass to the required new view. Since this member is a protected member, to change it I have derived my class 'CDynSplitter' from class CSplitterWnd. I have just added a function to change member m_pDynamicViewClass.


class CDynSplitter : public CSplitterWnd 
{ 
public: 

CDynSplitter() ; 
virtual ~CDynSplitter() ; 

void ChangeViewClass( CRuntimeClass *pNewView ) 
{ 
m_pDynamicViewClass = pNewView ; 
} 

// Other overridden functions ... 

};

You call this function and pass a CRuntimeClass pointer of new view. I have given a sample application, in which there are two views, one is a form view and another is a list view. In that I am just calling the same function so that the new view will be created of different type. I have also overridden a function DeleteView(int row, int col); to change m_pDynamicViewClass pointer to the view to be deleted, so that next time the deleted view will be created again.

Download demo project - 164 KB

Download source - 38 KB

Date Last Updated: February 8, 1999



Comments

  • splitters with form views

    Posted by Legacy on 03/31/2003 12:00am

    Originally posted by: hylepark

    i would like to create a splitter similar to the one you have here but not from the MainFrame object where one view is a FormView and the other is a normal CView. Any suggestions? THanks.

    Reply
  • Dynamic Splitter

    Posted by Legacy on 12/20/2000 12:00am

    Originally posted by: rajeev mc

    How can we have multiple views in the same pane.pls help

    Reply
  • How to keep Splitter Postion same when user changes size of the Window

    Posted by Legacy on 11/19/2000 12:00am

    Originally posted by: jay reddy

    I need a way to keep Splitter postion same, even
    
    when user changes the size of the window. when i resize
    the window, postion also should change, so that i sholud be able to see both rows.

    Reply
  • Printing problem

    Posted by Legacy on 08/11/1999 12:00am

    Originally posted by: Vicky

    Hi
    I have created a dynamic splitter(as shown in your article in Codeguru) having two different classes - CScrollView and CTreeView. I created view class as CScrollView using the AppWizard. Then I derived a class from CTreeView and added to create a splitter with these two classes.
    The problem I am facing is that when I click on the tree and open File menu, Print & Print Preview options are disabled. But when I click in the CScrollView and open File menu, Print & Print Preview options are enabled.

    Why this is happening?

    Thanx in advance

    Vicky

    Reply
  • 2 views in the same splitter pane

    Posted by Legacy on 07/26/1999 12:00am

    Originally posted by: Deelip Menezes

    I want to have two views in the same splitter pane.
    These views should be able to be swapped on the menu selection. Can you help?

    Reply
  • MDIChildWnd in a pane ?

    Posted by Legacy on 06/01/1999 12:00am

    Originally posted by: Laurent BERNARD

    And do you if it's possible to use a multi doc in a pane like in the editor of visual ?

    Reply
  • Assertion erros with CScrollView

    Posted by Legacy on 03/12/1999 12:00am

    Originally posted by: Steven Brekelmans


    When trying to use a splitter, one pain a CEditView the other a CScrollView, I'm getting a debug asserting error if I use the intellimouse scrolly wheel to scroll in the CScrollView window. Any ideas?

    Reply
  • How to keep a pane always be a square?

    Posted by Legacy on 02/25/1999 12:00am

    Originally posted by: zhang zhongyong

    Dear All experts on splitterWnd,

    I would like to know a simple method to realize my following idea:

    1. Split a window into two column; (that's easy)
    2. Keep the first pane always be a square automatically when users
    change the size of the window; (difficult, I cant implement)
    In my App, when changing the size of the window, I have to drag
    the splitter bar to keep the first pane being a square.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date