分享

VS2008 Outlookbar 介绍

 Frank_Chia 2010-07-16

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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多