原創(chuàng)|其它|編輯:郝浩|2013-01-08 10:13:18.000|閱讀 1001 次
概述:本文分步介紹了如何在應(yīng)用程序中添加BCGControlBar的Ribbon控件,并且附源碼。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文分步介紹了如何在應(yīng)用程序中添加BCGControlBar的Ribbon控件,并且附源碼。
1、打開MainFrme.h,移除CBCGPMenuBar、 m_wndMenuBar、CBCGPToolBar、 m_wndToolBar。
2、對Ribbon Bar和主要的 Ribbon Button添加自定義。
CBCGPRibbonBar m_wndRibbonBar; CBCGPRibbonMainButton m_MainButton;
3、添加定義面板圖像列表。
CBCGPToolBarImages m_PanelIcons;
4、打開MainFrm.cpp,移除m_wndMenuBar 和m_wndToolBar有關(guān)的東西。
5、對源添加一個(gè)Ribbon Main Button(IDB_MAIN)26X26像素的位圖,小圖標(biāo)(16像素高度)的位圖列表以及大圖標(biāo)(32像素高度)位圖列表,并將他們命名為IDB_SMALL_ICONS和IDB_LARGE_ICONS respectively。
6、在CMainFrame::OnCreate中創(chuàng)建Ribbon Bar:
m_wndRibbonBar.Create (this);
7、初始化和設(shè)置主要的Ribbon Button:
m_MainButton.SetMenu (IDR_FILE_MENU); m_MainButton.SetImage (IDB_MAIN); m_MainButton.SetToolTipText (_T("File")); m_wndRibbonBar.SetMainButton (&m_MainButton, CSize (45, 45));
8、初始化和加載面板圖標(biāo)的圖像列表。
m_PanelIcons.SetImageSize (CSize (16, 16)); m_PanelIcons.Load (IDB_PANEL_ICONS);
9、添加第一類:
CBCGPRibbonCategory* pCategory = m_wndRibbonBar.AddCategory (_T("&Write"), // Category name IDB_WRITE, // Category small images (16 x 16) IDB_WRITE_LARGE); // Category large images (32 x 32)
10、添加第一個(gè)面板到這個(gè)類別:
CBCGPRibbonPanel* pPanel = pCategory->AddPanel ( _T("Clipboard"), // Panel name m_PanelIcons.ExtractIcon (0)); // Panel icon
11、添加ribbon元素到面板:
// Create the first button to Panel ("Paste"): CBCGPRibbonButton* pPasteButton = new CBCGPRibbonButton (ID_EDIT_PASTE, _T("Paste"), -1, 0); // The third parameter (-1) tells that this button does not have a small icon. // Therefore the "Paste" button will be always displayed with large icon. // Associate a popup menu with the "Paste" button: pPasteButton->SetMenu (IDR_CONTEXT_MENU); // Add other buttons to the panel. These buttons have small icons only: pPanel->Add (new CBCGPRibbonButton (ID_EDIT_CUT, _T("Cut"), 1)); pPanel->Add (new CBCGPRibbonButton (ID_EDIT_COPY, _T("Copy"), 2)); pPanel->Add (new CBCGPRibbonButton (ID_EDIT_PAINT, _T("Paint"), 9));
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件