Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Extended Splitter Window Class

0.00/5 (No votes)
26 Apr 2001 5  
An extended splitter window class that makes creating 'T' style layouts simple

Sample Image - CExSplitter3Wnd.jpg

Introduction

I needed a 3 window splitter that will split the window in a "T" shape as opposed to 3 columns or 3 rows. This CExSplitter3Wnd class will allow you to create a 3 window splitter according to a pre-defined layout. Below are the patterns that are defined. Note that you can add any layout you wish:

Note that PATTERN_5 and PATTERN_6 are created the usual way. The other 4 patterns show the extended style.

To create one of those patterns:

  1. Override the OnCreateClient function in your SDI MainFrame.
  2. Construct a new CExSplitter3Wnd object.
  3. Set style and initial view sizes.
  4. Call the set pattern function with the following parameters:
    • CWnd* pParent
    • SPLIT_PATTERN SplitPattern
    • CRuntimeClass* pFirstView
    • CRuntimeClass* pSecView
    • CRuntimeClass* pThirdView
    • CCreateContext* pContext

SPLIT_PATTERN is an enum defined:

typedef enum 
{
    PATTERN_1 ,
    PATTERN_2 ,
    PATTERN_3 ,
    PATTERN_4 ,
    PATTERN_5 ,
    PATTERN_6 ,

}SPLIT_PATTERN;

Example:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    // TODO: Add your specialized code here and/or call the base class

    m_pTopWndSplitter  = new CExSplitter3Wnd;

    m_pTopWndSplitter->SetStyle(WS_CHILD | WS_VISIBLE | WS_BORDER);
    m_pTopWndSplitter->SetFirstViewSize(CSize(100,100));
    m_pTopWndSplitter->SetSecondViewSize(CSize(100,200));
    m_pTopWndSplitter->SetThirdViewSize(CSize(100,100));
    m_pTopWndSplitter->SetPattern(this,PATTERN_1,
        RUNTIME_CLASS(CTestSplitView),RUNTIME_CLASS(CSecView),
        RUNTIME_CLASS(CThirdView),pContext);
    return TRUE;
}

You can retrieve the different view sizes by calling one of the dimension functions. Each view (first, second, third) has its own function:

void GetFirsWndDim(int* nCurrDim,int* nMinDim);
void GetSecWndDim(int* nCurrDim,int* nMinDim);
void GetThirdWndDim(int* nCurrDim,int* nMinDim);

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here