《 BCG 原创 :系列 二》 基本设置:将MFC项目 修改 成为BCG 项目

 

  1. 添加下列语句到 stdafx.h 文件: #include "BCGCBProInc.h" 
  1. 为自己的App类添加基类CBCGPWorkspace。

如:class CMyApp : public CWinApp, public CBCGPWorkspace

  1. 在App类的ExitINstance()函数中添加BCGCBProCleanUp()

(注意: 你可能找不到这个方法, 自己继承 APP 的这个方法,并实现)

  1. 确定 在   InitInstance() 中调用 了 AfxOleInit()

 

  1. 5.       你必须定义在注册表中存放你自定义数据的位置和你 需要什么样的自定义(鼠标、键盘、上下文菜单),为了做这些工作

         在CMyApp::InitInstance 中设置注册表入口并初始化

         自定义管理器:   SetRegistryBase (_T("Settings"));

         // 初始化自定义管理器:

                                             InitMouseManager();

                                             InitContextMenuManager();

                                              InitKeyboardManager();

 

  1. 在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.  生成程序,并执行它,可以看到这个菜单啦·而且是可以移动的哦

原文地址:https://www.cnblogs.com/gdutbean/p/2379598.html