- 添加下列語句到 stdafx.h 文件: #include "BCGCBProInc.h"
- 為自己的App類添加基類CBCGPWorkspace。
如:class CMyApp : public CWinApp, public CBCGPWorkspace
- 在App類的ExitINstance()函數中添加BCGCBProCleanUp()。
(注意: 你可能找不到這個方法, 自己繼承 APP 的這個方法,並實現)
- 確定 在 InitInstance() 中調用 了 AfxOleInit();
- 5. 你必須定義在注冊表中存放你自定義數據的位置和你 需要什么樣的自定義(鼠標、鍵盤、上下文菜單),為了做這些工作,
在CMyApp::InitInstance 中設置注冊表入口並初始化
自定義管理器: SetRegistryBase (_T("Settings"));
// 初始化自定義管理器:
InitMouseManager();
InitContextMenuManager();
InitKeyboardManager();
- 在StdAfx.h中添加如下代碼
#define CFrameWnd CBCGPFrameWnd
#define CMDIFrameWnd CBCGPMDIFrameWnd
#define CMDIChildWnd CBCGPMDIChildWnd
#define CToolBar CBCGPToolBar
#define CStatusBar CBCGPStatusBar
這樣做的目的是將 MDI中的一些類用BCGControlBar來進行轉換,轉換如下:
CFrameWnd -> CBCGPFrameWnd ;
CMDIFrameWnd -> CBCGPMDIFrameWnd
CMDIChildWnd -> CBCGPMDIChildWnd ;
CToolBar -> CBCGPToolBar ;
CStatusBar -> CBCGPStatusBar.
二、添加功能 –為CmaimFrame類添加嵌入菜單對象。
1. 在CmainFrame類中添加成員變量 CBCGPMenuBar m_wndMenuBar。
2. 然后在其OnCreate函數中加入如下代碼:
m_wndMenuBar.Create (this);
m_wndMenuBar.EnableDocking (CBRS_ALIGN_ANY);
DockControlBar (&m_wndMenuBar);
或者:
if(!m_wndMenuBar.Create (this)){
TRACE0("創建 BCG MENU 失敗");
return -1;
}
m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY| CBRS_SIZE_DYNAMIC);
m_wndMenuBar.EnableDocking (CBRS_ALIGN_ANY);
DockControlBar (&m_wndMenuBar);
3. 在CMainFrame::OnCreate的開始加入應用程序可視化的風格。
例如:
CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGPVisualManager));
其函數原型如下:
CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (manager));
其中manager的取值與風格對照如下:
CBCGPVisualManager |
MS Office 2000/VC++ 6.0 look |
CBCGPVisualManagerXP |
MS Office XP/Visual Studio.NET look |
CBCGPVisualManager2003 |
MS Office 2003 look |
CBCGPVisualManagerVS2005 |
Visual Studio 2005 look |
CBCGPWinXPVisualManager |
Native Windows XP/Vista/Windows 7 look. |
CBCGPVisualManager2007 |
MS Office 2007 look |
CBCGPVisualManagerVS2008 |
Visual Studio 2008 look |
CBCGPVisualManagerVS2010 |
Visual Studio 2010 look |
CBCGPVisualManager2010 |
MS Office 2010 look |
CBCGPVisualManagerScenic |
Windows 7 Ribbon look. |
4. 生成程序,並執行它,可以看到這個菜單啦·而且是可以移動的哦