Click here to Skip to main content
Licence CPOL
First Posted 16 Sep 2008
Views 18,119
Bookmarked 20 times

Embedding CMFCOutlookBar in CSplitterWnd panes

By | 16 Sep 2008 | Article
Create a 2008 MFCOutlookBar in any pane of a SplitterWnd.

Introduction

This article helps to add a CMFCOutlookbar in CSplitterWnd panes. The above image shows an Office 2007 type UI that is available with Visual Studio 2008 and the MFC feature pack. Refer this link for more details: Visual C++ 2008 Feature Pack: MFC Enhancements.

Using the code

By default, the CMFCOutlookBar in the Office 2007 UI generated code is embedded in a CFrameWnd derived class. Here, we will discuss about adding a CMFCOutlookBar in CSplitterWnd/CSplitterWndEx panes.

BOOL COffice2007Frame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,    
                       CCreateContext* pContext)
{
    BOOL bRet=true;  
    bRet=bRet&m_wndSplitter.CreateStatic(this,2,2);
    CRect rectClient;
    this->GetClientRect(&rectClient); 
    bRet=bRet&m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMFCOutlookBar),
         CSize(rectClient.Width()/4,rectClient.Height()/2),pContext); 
    bRet=bRet&m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(COffice2007View),
         CSize(rectClient.Width()*3/4,rectClient.Height()/2),pContext); 
    bRet=bRet&m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(COffice2007View),
         CSize(rectClient.Width()/4,rectClient.Height()/2),pContext); 
    bRet=bRet&m_wndSplitter.CreateView(1,1,RUNTIME_CLASS(COffice2007View),
         CSize(rectClient.Width()*3/4,rectClient.Height()/2),pContext);      
    return bRet;  
}

This above code divides the splitter window in four unequal panes. During the creation of the view in the first pane, a CMFCOutlookBar runtime pointer is given, so it will create an OutlookBar in the first pane.

CMFCOutlookBar* pPane_0_0=(CMFCOutlookBar*)m_wndSplitter.GetPane(0,0);
pPane_0_0->GetParent()->ModifyStyle(WS_CHILDWINDOW,WS_CHILDWINDOW|
                                    WS_CLIPCHILDREN,SWP_DRAWFRAME);

In the above code, we take the pointer of the OutlookBar using the GetPane function and modify the properties of the splitter parent pane to add the WS_CLIPCHILDREN property. If we don't add this property, then on focus change, the splitter window pane will over-paint the OutlookBar.

By changing this property, it creates a problem of debug assertion fail in the Debug compile mode. To solve this problem, derive the class CSplitterWndEx and override the function OnInvertTracker().

void CDSplitterWndEx::OnInvertTracker(const CRect& rect )
{
    this->GetPane(0,0)->GetParent()->ModifyStyle(WS_CLIPCHILDREN,
                        0,SWP_DRAWFRAME);
    this->GetPane(0,1)->GetParent()->ModifyStyle(WS_CLIPCHILDREN,
                        0,SWP_DRAWFRAME);
    this->GetPane(1,0)->GetParent()->ModifyStyle(WS_CLIPCHILDREN,
                        0,SWP_DRAWFRAME);
    this->GetPane(1,1)->GetParent()->ModifyStyle(WS_CLIPCHILDREN,
                        0,SWP_DRAWFRAME);

    CSplitterWndEx::OnInvertTracker(rect); //Base class

    this->GetPane(0,0)->GetParent()->ModifyStyle(0, 
                        WS_CLIPCHILDREN,SWP_DRAWFRAME);
    this->GetPane(0,1)->GetParent()->ModifyStyle(0,
                        WS_CLIPCHILDREN,SWP_DRAWFRAME);
    this->GetPane(1,0)->GetParent()->ModifyStyle(0,
                        WS_CLIPCHILDREN,SWP_DRAWFRAME);
    this->GetPane(1,1)->GetParent()->ModifyStyle(0,
                        WS_CLIPCHILDREN,SWP_DRAWFRAME);
}

The above code removes the WS_CLIPCHILDREN property of each pane before calling OnInverTracker to escape from a debug assertion fail, and then again adds the property back to each pane.

Points of Interest

This code is particularly useful for those who want to modify the MFC Outlook 2008 in their own way. This just demonstrates how to add a CMFCOutlookBar in a SplitterWnd pane in place of the default main frame window.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

vikas maan

Software Developer (Senior)

India India

Member

Vikas Maan is a software developer for last 4 years working on windows platform with multiple programming languages mainly VC++, C#.net etc.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 Pinmembercute_friend70772:52 14 Jun '10  
GeneralHelp me! Thanks! Pinmemberqidaimengxing22:58 9 Mar '09  
QuestionWhere can I obtain this source code? Pinmemberlanlamer2:14 23 Feb '09  
AnswerRe: Where can I obtain this source code? Pinmembervikas maan5:50 4 Mar '09  
AnswerRe: Where can I obtain this source code? PinmemberBarretto VN4:32 3 Nov '11  
GeneralRemove MFC Pinmemberjit_infy23:50 13 Oct '08  
QuestionHow can you used these new controls in C# PinmemberPatrick Blackman5:23 18 Sep '08  
AnswerRe: How can you used these new controls in C# Pinmembervikas maan0:05 19 Sep '08  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 16 Sep 2008
Article Copyright 2008 by vikas maan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid