BOOL CMainFrame
::CreateStatusBar()
{
if (
!m_wndStatusBar.Create(
this))
{
TRACE0(
"Failed to create status bar\n");
return FALSE;
}
//创建连接按钮
m_wndStatusBar.AddElement(
new CMFCRibbonLinkCtrl(ID_STATUSBAR_LINK, _T(
"www.microsoft.com"), _T(
"http://www.microsoft.com")), _T(
"Link to website"));
//分隔符
m_wndStatusBar.AddSeparator();
//面板--按钮---所有的按钮在StatusBar里都叫面板
m_wndStatusBar.AddElement(
new CMFCRibbonStatusBarPane(ID_STATUSBAR_PAGE, _T(
"Page 1")), _T(
"Formatted Page Number"));
m_wndStatusBar.AddElement(
new CMFCRibbonStatusBarPane(ID_STATUSBAR_LINE, _T(
"Line 1")), _T(
"Line Number"));
//分隔符
m_wndStatusBar.AddSeparator();
//创建一个拼写动画按钮 ->
HICON hIconSpell
= (HICON)
::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SPELL), IMAGE_ICON,
::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON), LR_SHARED);
m_wndStatusBar.AddElement(
new CMFCRibbonStatusBarPane(ID_STATUSBAR_SPELL, _T(
""), (
UINT) IDB_SPELL,
16, RGB(
212,
212,
212), hIconSpell), _T(
"Spelling and Grammar Check"));
//分隔符
m_wndStatusBar.AddSeparator();
//刷新按钮的图标
HICON hIconRefresh
= (HICON)
::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_REFRESH), IMAGE_ICON,
::GetSystemMetrics(SM_CXSMICON),
::GetSystemMetrics(SM_CYSMICON), LR_SHARED);
//刷新按钮
m_wndStatusBar.AddElement(
new CMFCRibbonStatusBarPane(ID_STATUSBAR_REFRESH, _T(
"Refresh"), FALSE, hIconRefresh), _T(
"Refresh"));
//stl的智能指针分配用来创建按钮群
std
::auto_ptr
<CMFCRibbonButtonsGroup
> apSBGroup(
new CMFCRibbonButtonsGroup);
CMFCToolBarImages images1;
images1.SetImageSize(CSize(
14,
14));
images1.Load(IDB_LAYOUT);
apSBGroup
-
>SetImages(
&images1, NULL, NULL);
apSBGroup
-
>SetID(ID_GROUP_SHORTCUTS);
apSBGroup
-
>AddButton(
new CMFCRibbonButton(ID_STATUSBAR_PRINTLAYOUT, _T(
""),
0));
apSBGroup
-
>AddButton(
new CMFCRibbonButton(ID_STATUSBAR_FULL_SCREEN_READING, _T(
""),
1));
apSBGroup
-
>AddButton(
new CMFCRibbonButton(ID_STATUSBAR_WEBLAYOUT, _T(
""),
2));
apSBGroup
-
>AddButton(
new CMFCRibbonButton(ID_STATUSBAR_MASTER_DOCUMENT_TOOLS, _T(
""),
3));
apSBGroup
-
>AddButton(
new CMFCRibbonButton(ID_STATUSBAR_DRAFT, _T(
""),
4));
//按钮群属于ExtendedElement,既是右边的那一栏
m_wndStatusBar.AddExtendedElement(apSBGroup.release(), _T(
"View Shortcuts"));
//缩放按钮
m_wndStatusBar.AddExtendedElement(
new CMFCRibbonStatusBarPane(ID_STATUSBAR_ZOOM, _T(
"100%"), FALSE, NULL, _T(
"1000%")), _T(
"Zoom"));
//Ribbon滑竿按钮
CMFCRibbonSlider
* pSlider
=
new CMFCRibbonSlider(ID_STATUSBAR_ZOOM_SLIDER);
pSlider
-
>SetZoomButtons();
pSlider
-
>SetRange(
0,
200);
pSlider
-
>SetPos(
100);
m_wndStatusBar.AddExtendedElement(pSlider, _T(
"Zoom Slider"));
return TRUE;
}