Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / MFC

Extended Splitter Window Class

Rate me:
Please Sign up or sign in to vote.
3.65/5 (14 votes)
26 Apr 20011 min read 180.5K   3.9K   34   26
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:

Image 2

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:

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

}SPLIT_PATTERN;

Example:

C++
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:

C++
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.


Written By
Ran
Israel Israel
C++ Developer

Comments and Discussions

 
Generalsplit window sizing Pin
kittunair14-May-05 0:14
kittunair14-May-05 0:14 
GeneralFix Splitter 3rd Pane Pin
Vikram Kashyap16-May-04 23:02
Vikram Kashyap16-May-04 23:02 
Questionhow to create controls in the splitterwindows Pin
Priya Su9-May-04 20:05
Priya Su9-May-04 20:05 
AnswerRe: how to create controls in the splitterwindows Pin
Vikram Kashyap16-May-04 23:35
Vikram Kashyap16-May-04 23:35 
GeneralThanks! Pin
Spectrum_12-Oct-03 22:39
Spectrum_12-Oct-03 22:39 
QuestionHow to do this case? Pin
ericlts2-Apr-03 14:39
ericlts2-Apr-03 14:39 
Generalsplitting and un-splitting Pin
2-Jul-02 4:47
suss2-Jul-02 4:47 
how to show (add) and hide (remove) panes at will at run time ?
QuestionDisplaying non-split window as well split window? Pin
mohanrajh4-May-02 17:34
mohanrajh4-May-02 17:34 
GeneralHELP ACESS METHOD Pin
13-Mar-02 6:04
suss13-Mar-02 6:04 
GeneralGood Job ;-) Pin
5-Mar-02 16:24
suss5-Mar-02 16:24 
QuestionHow to transfer datas between views in Spliter window Pin
29-Jan-02 0:10
suss29-Jan-02 0:10 
AnswerRe: How to transfer datas between views in Spliter window Pin
Wan Ling Li5-Apr-04 3:59
Wan Ling Li5-Apr-04 3:59 
QuestionHow to switch views in the third pan Pin
13-Dec-01 8:11
suss13-Dec-01 8:11 
GeneralMore Splits Pin
11-Jul-01 11:03
suss11-Jul-01 11:03 
GeneralRe: More Splits Pin
John P. Curtis30-Jan-02 17:47
John P. Curtis30-Jan-02 17:47 
GeneralNot extensible Pin
Datacrime30-Apr-01 3:51
Datacrime30-Apr-01 3:51 
GeneralRe: Not extensible Pin
3-Jun-01 4:42
suss3-Jun-01 4:42 
GeneralNot necessary Pin
29-Apr-01 0:09
suss29-Apr-01 0:09 
GeneralRe: Not necessary Pin
29-Apr-01 8:42
suss29-Apr-01 8:42 
GeneralRe: Not necessary Pin
3-Jun-01 4:46
suss3-Jun-01 4:46 
GeneralRe: Not necessary Pin
sanvm10-Aug-03 21:03
sanvm10-Aug-03 21:03 
GeneralRe: Not necessary Pin
hewat13-Nov-03 3:43
hewat13-Nov-03 3:43 
GeneralMemory leaks Pin
MoZ27-Apr-01 6:53
MoZ27-Apr-01 6:53 
GeneralRe: Memory leaks Pin
3-Jun-01 4:49
suss3-Jun-01 4:49 
GeneralRe: Memory leaks Pin
lio18-Feb-02 7:02
lio18-Feb-02 7:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.