Different Views In Dynamic Splitter | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 8, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.