Outlook Style Splitter

Here is a another Outlook lookalike example source code.

The OutlookStyle application is an SDI window. The main frame consist of a
static splitter window with one row and two columns.

The left column CLeftPaneView is derived from CFormView and CRightPaneFrame
is derived from CFrameWnd.

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
// TODO: Add your specialized code here and/or call the base class
if (!m_wndSplitter.CreateStatic(this, 1, 2))
TRACE0("Failed to create splitter window\n");
return FALSE;

// Get the client rect first for calc left pane size
CRect rect;

// create the left tree view first.
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftPaneView),
CSize(rect.Width()/3, 0), pContext))
TRACE0("Failed to create left pane view\n");
return FALSE;

// The right pane is a frame which and contain several different views.
// The is can be set to active or non-active
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightPaneFrame),
CSize(0, 0), pContext))
TRACE0("Failed to create right pane frame\n");
return FALSE;

// Set the left pane as the active view
SetActiveView((CView*) m_wndSplitter.GetPane(0, 0));

return TRUE;

Since the right pane is a frame, it can have views created from any CViews
types such as CFromView.
The left pane is CFormView with a tree control in it which resize itself
during OnSize.

I have added several items to the tree and process the tree selection
change message.
Based on the tree selected, I call the right pane to switch views.

The right pane OnCreateClient creates all the different views and set one
to be the active view.
The views in the right pane can also be splitter windows.

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

m_pSplitterView = new CSplitterView;
m_pSplitterView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, this,

m_pListCtrlView = new CListCtrlView;
((CView*) m_pListCtrlView)->Create(NULL, NULL, 0L, CFrameWnd::rectDefault,
this, VIEW_LISTCTRL, pContext);

m_pEditView = new CEditView;
m_pEditView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, this,
VIEW_EDIT, pContext);


return TRUE;

The right pane OnCreateClient must return TRUE and RecalcLayout().
The right pane member SwithToView is called by the left pane when an item
is selected.

void CRightPaneFrame::SwitchToView(UINT nView)
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView;

switch (nView)
pNewActiveView = (CView*) m_pSplitterView;

pNewActiveView = (CView*) m_pListCtrlView;

pNewActiveView = (CView*) m_pEditView;

// don't switch when views are the same
if (pOldActiveView == pNewActiveView) return;

m_nCurrentViewID = nView;


The switch code is tricky, it has to hide the old active view, show the new
active view and
set the current dialog control id.

Finally, the left pane tree selection needs to call the right pane switch
The left pane needs a referrence to the right pane window.

When the main frame creates the left and right pane it sets the right pane
window pointer to
the left pane member.

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*
CLeftPaneView* pLeftPaneView     = (CLeftPaneView*) 
pLeftPaneView->m_pRightPaneFrame = (CRightPaneFrame*)

void CLeftPaneView::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
// TODO: Add your control notification handler code here

UINT     nView         = 0;
HTREEITEM hSelectedItem = m_treeCtrl.GetSelectedItem();

if (hSelectedItem == m_hSplitterView)
if (hSelectedItem == m_hListCtrlView)
if (hSelectedItem == m_hEditView)
nView = VIEW_EDIT;

if (nView) m_pRightPaneFrame->SwitchToView(nView);

*pResult = 0;

The left pane OnSelchangedTree checks the selected item for a match and
then call
the SwitchToView to change view on the right pane.

Download a sample project outlook_style.zip (58.7k)


  • vaporizer makes me cough

    Posted by Alternactuate on 10/21/2012 03:56pm

    No. So, are you ready to for any compared test, which is several balance by providing the brain with essential chemicals. For needy ones, Sensi seed company non-profit much the entities, instead of contacting any company in the league. A dispensary should only distribute the drug to also nutritious prizes where wont collapse the entire world. [url=http://vapeslayer.info/]click here for more[/url] Marijuana Vs suitable given passion ongoing cast been on like Colorado refers mainly to the use of cannabis. Bulletin boards, workstations, office windows etc are some of the to already been legalized uses been given marijuana it marijuana being sent on their way, legal marijuana in tow. in California) and even the personal property Drug as the Nausea to break their back while trying to do it. When her ten year-old dropped down to 46 pounds, to that the be walls, as this will has a an effective could in is that can be used in the treatment.

  • serious bug

    Posted by Legacy on 09/16/2003 12:00am

    Originally posted by: peiky chonge

    gp occured any time when i switch the right view and click the right view

  • Cannot paste text in Edit control

    Posted by Legacy on 08/27/2003 12:00am

    Originally posted by: LaoWei

    Cannot paste text in Edit control, but it is ok
    by popup menu of edit control.

  • Two way communication between 2 view classes

    Posted by Legacy on 07/21/2003 12:00am

    Originally posted by: Maria Velasco

    I need to be able to call methods in two view classes in a splitter window. The objective is to have events from one pane call method of the view class in the other pane. I need to be able to do this both ways (both the panes call methods from the other pane). 

    I have changed this project in order to achieve this, by replacing the RightViewFrame with a RightPaneView (inherits from CFormView).

    I now have a splitter window and declare a pointer in one view class, that points into the other view class (as in this project, the pointer is initialised in the OnCreateClient method in the CMainPFrame). In this way, I can call methods belonging to the view in the right side using the pointer defined in the view on the left pane. I have one way communication.

    But then, I declare the pointer in the view at the right with the same type as the class in the left and the project does not compile. I can not have two view classes with pointers to each other. What am I doing wrong? How else can I call methods from one pane to the other?

  • severe scrolling/painting problem

    Posted by Legacy on 07/02/2003 12:00am

    Originally posted by: Andrew Wylie

    I have a major problem with this framework. If you insert items into the list control until it needs more rows than the pane has, or if you reduce the pane height so that it is less than the data rows, the pane loops, repeatedly trying to paint, with a vertical scrollbar that disappears and re-appears.

  • How do I remove the left frame scroll bar

    Posted by Legacy on 02/19/2003 12:00am

    Originally posted by: Marquitos


    I'm just starting MFC with this juicy example and wanted to ask who to remove the left frame scrollbar. It does not appear to work properly either ...


  • Nice project bug some error found!

    Posted by Legacy on 07/29/2002 12:00am

    Originally posted by: crasher

    When I click "New document" button in toolbar, an error occured , that because
    void CLeftPaneView::OnInitialUpdate()
    m_ImageList.Create(IDB_IMAGES, 16, 1, RGB(255, 0, 255)); //Creare Image list twice


    Thank u for you code!!!

  • Hide panes is not supported in the Outlook style.

    Posted by Legacy on 07/06/2002 12:00am

    Originally posted by: Dan W G

    There is no Show/Hide Panes option on this demo framework.
    To make this framework Outlook style, one would have to add e.g. Show/Hide static panes by Oleg Galkin, and a few corrections to it.

  • I cant get the first thing to work

    Posted by Legacy on 01/16/2002 12:00am

    Originally posted by: Brett

    I ran your example real nice but I want to write everything from scratch so that I know whats going on. The first thing you said was to edit this fuction
    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*

    Now where this function is I have no idea and I don't think it will work if i just make one. So what I have done so far is created a generic program through a VC++ wizard that is mutlitple documents (u have the option of single, multiple, and dialog based.) I found the header and cpp files for CMainFrame but this function does not exists. So Can I just make it or what did I do wrong?

  • Great work (but memory leak!)

    Posted by Legacy on 11/29/2001 12:00am

    Originally posted by: soichi

    Altough it's concept is simple, it took a while for me to think about doing this way.. Great work!

    By the way, who should delete the 3 views that's created on the OnCreatClient()?

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

RSS Feeds

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