在VS2010中使用Outlook工具栏

参考资料:微软MSDN、VS2010示例代码


一开始上段子总是能活跃气氛,等哪天我再打开自己的这篇博客,总是能够让自己傻傻的乐一下。

我一女同学,毕业去一大公司应聘,竞争很激烈,最后剩下她和一位女士.两个人都很优秀,面试官犹豫着叫她们两明天再来.临走之前她捡起了地上的碎纸屑,所以说细节决定成败!就是这么一个不经意的弯腰,被路过的CEO看到了.CEO透过衣领看到她的胸特别小,于是当机立断录取了另一位女士.醒醒吧!现实就是这样!不会有人想揍我吧?

大致结构

Bar

|--TabCtrl

        |--Pan

              |--Button


变量定义

CMFCOutlookBar m_OutlookBar;
CMFCOutlookBarPane m_OutlookPage;

实现代码

BOOL CMainFrame::CreateShortcutsBar ()
{
	CMFCOutlookBarTabCtrl::EnableAnimation ();

	const int nInitialWidth = 150;
	const CString strCaption = _T("Shortcuts");

	if (!m_OutlookBar.Create (strCaption, this, 
		CRect (0, 0, nInitialWidth, nInitialWidth), 
		ID_OUTLOOK_BAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT))
	{
		TRACE0("Failed to create outlook bar
");
		return FALSE;      // fail to create
	}

	CMFCOutlookBarTabCtrl* pOutlookBarTabCtrl = DYNAMIC_DOWNCAST (CMFCOutlookBarTabCtrl, m_OutlookBar.GetUnderlyingWindow ());
	if (pOutlookBarTabCtrl == NULL)
	{
		TRACE0("Cannot get outlook bar container
");
		return FALSE;
	}

	CImageList images;
	images.Create (IDB_BMP_SHORTUTS, 32, 0, RGB (255, 0, 255));

	// Create first page:
	m_OutlookPage.Create (&m_OutlookBar, AFX_DEFAULT_TOOLBAR_STYLE, ID_OUTLOOK_PAN1);
	m_OutlookPage.SetOwner (this);
	m_OutlookPage.EnableTextLabels();
	m_OutlookPage.EnableDocking (CBRS_ALIGN_ANY);

	m_OutlookPage.AddButton (images.ExtractIcon (0), _T("实时"), ID_BTN_VIEW1);
	m_OutlookPage.AddButton (images.ExtractIcon (1), _T("历史"), ID_BTN_VIEW2);

	pOutlookBarTabCtrl->AddTab (&m_OutlookPage, _T("界面"), (UINT)-1, FALSE);

	return TRUE;
}

这段代码修改并截取自微软的示例程序OutlookMultiViews

但是这块代码跟VS2010的SDI中自带的Outlook工具栏的实现是不一样的。

原文地址:https://www.cnblogs.com/wlsandwho/p/4202110.html