打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VS2008 Outlookbar 介绍

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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
MFC在窗口创建后动态改变窗口的风格
创建大窗口
ModifyStyle函数的用法
关于WS_CLIPCHILDREN和WS_CLIPSIBLINGS的理解
Transparent TCustomcontrol
RedrawWindow(NULL, NULL, RDW
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服