原創|其它|編輯:郝浩|2012-06-11 03:25:37.000|閱讀 4244 次
概述:BCGControlBar主要用于構建類似Microsoft Office/Visual Studio界面效果。BCGControlBar安裝好后,在開始使用前,還需要了解一些初始化設置以及BCGControlBar使用方法和技巧需要了解一下。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
BCGControlBar是全球最大的MFC控件套包,由微軟指定合作控件開發商BCGSoft公司開發,主要用于構建類似Microsoft® Office 2000/XP/2003/2007/2010、Microsoft Visual Studio(打印、用戶定制工具欄、菜單等)和其他一些知名產品的高級用戶界面,例如:日歷、網格、編輯和甘特圖等。本文主要通過代碼介紹了BCGControlBar的初始化設置以及使用方法和技巧。
首先下載并安裝(BCGControlBar下載地址)。BCGControlBar安裝好后,在開始使用前,還需要了解一些初始化設置以及BCGControlBar使用方法和技巧需要了解一下。
首先,請你按以下內容修改源碼:
#include "BCGCBProInc.h"有關庫版本將自動鏈接到你的項目中。
class CMyApp : public CWinApp, public CBCGPWorkspace
SetRegistryBase (_T("Settings")); // 初始化定制管理器: InitMouseManager(); InitContextMenuManager(); InitKeyboardManager();
class CMyApp .... { ... virtual void PreLoadState(); ... }; void CMyApp::PreLoadState() { // 把鼠標事件連接到特定的視圖 : GetMouseManager()->AddView (iIdTestView, _T("Test view"), IDR_VIEW); // 初始化上下文菜單: GetContextMenuManager()->AddMenu (_T("Test menu"), idMenu); }
CBCGPMenuBar m_wndMenuBar; // 新菜單欄 CBCGPToolBar m_wndToolBar; // 應用程序工具欄
// 創建菜單欄(替換標準菜單欄): if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // 創建失敗 } m_wndMenuBar.SetBarStyle (m_wndMenuBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndMenuBar.EnableDocking (CBRS_ALIGN_ANY); DockControlBar (&m_wndMenuBar);
提示:你可以在程序中使用任意數量的CBCGToolBar工具欄。所有的工具欄圖像將被合并到一個位圖文件中。無論如何,只有一個CBCGMenuBar對象被使用。
啟用工具欄/菜單自定義功能,請做如下修改:
void CMainFrame::OnViewCustomize() { // 創建一個自定義工具欄對話框: CBCGPToolbarCustomize* pDlgCust = new CBCGPToolbarCustomize (this, TRUE /* Automatic menus scaning */); // 添加預定義工具欄: pDlgCust->AddToolBar ("Main", IDR_MAINFRAME); .... // 添加用戶自定義命令: pDlgCust->AddButton ("User", CBCGPToolbarButton (ID_USER_TOOL1, 1, "User Tool 1", TRUE)); pDlgCust->AddButton ("User", CBCGPToolbarButton (ID_USER_TOOL2, 2, "User Tool 2", TRUE)); pDlgCust->AddButton ("User", CBCGPToolbarButton (ID_USER_TOOL3, 3, "User Tool 3", TRUE)); .... pDlgCust->SetUserCategory ("User"); // 啟用用戶自定義工具欄的 創建/刪除: pDlgCust->EnableUserDefinedToolbars (); pDlgCust->Create (); }
啟用Microsoft Office 2000菜單:
CList<UINT, UINT> lstBasicCoomads; lstBasicCoomads.AddTail (ID_FILE_NEW); lstBasicCoomads.AddTail (ID_FILE_OPEN); lstBasicCoomads.AddTail (ID_FILE_SAVE); ...... lstBasicCoomads.AddTail (ID_APP_ABOUT); CBCGPToolBar::SetBasicCommands (lstBasicCoomads);
以下代碼可以實現運行時改變菜單字體:
CBCGPMenuBar::SetMenuFont (LPLOGFONT lpLogFont, BOOL bHorz = TRUE);
只需調用即可實現“頁面”(自定義)按鈕:
m_wndToolBar.EnableCustomizeButton (TRUE, id_of_customize_command, _T("Customize..."));
以下代碼可以實現按鈕圖像覆蓋文字:
m_wndToolBar.EnableTextLabels (BOOL bEnable = TRUE);
實現用戶自定義工具欄:
ID_TOOL1 "Activates user-defined tool\nUser Tool" ID_TOOL2 "Activates user-defined tool\nUser Tool" .... ID_TOOLx "Activates user-defined tool\nUser Tool"
EnableUserTools (ID_TOOLS_ENTRY, ID_TOOL1, ID_TOOLx);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網