BCG界面库在VC工程中的应用步骤

BCGControlBarLibrary Professional Edition installation:

整个库的源代码安装在<installdir>\BCGCBPro目录下面.可执行文件(*.dll)安装在 <install dir>\Bin (for VisualStudio 6.0) <installdir>\Bin7 (for VisualStudio.NET)下面。

请在你的源代码中做如下的改变:

·                            在应用程序的Include路径中加入BCGCBPro目录,具体添加办法如下:vs2005下面打开菜单工具的Option项,选择项目解决方案-vc++目录,然后将包含文件<installdir>\BCGCBPro添加进去。

·                            确信在你的应用程序的 InitInstance() 方法中调用了AfxOleInit()

·                            stdafx.h中加入下面的包含文件:

#include "BCGCBProInc.h"

·                            使你的应用程序派生自:CBCGPWorkspace

classCMyApp : publicCWinApp,
                        
publicCBCGPWorkspace

·                            第一步,你需要定义一个在注册表里保存个性化数据的项并且鼠标,键盘和上下文菜单都需要。为了实现这一点,CMyApp::InitInstance set registry entry and initializecustomization managers:

SetRegistryBase (_T("Settings"));

// Initialize customization managers:
InitMouseManager();
InitContextMenuManager();
InitKeyboardManager();

·                            如果你决定使你的鼠标和菜单具有个性化,你需要 "attach"一个需要的视图初始化鼠标和菜单的个性化管理。重载 CBCGPWorkspace::PreLoadState方法:

classCMyApp ....
{
...

virtual voidPreLoadState();
...
};


voidCMyApp::PreLoadState()
{
   
// Associate mouse event with specific view(s):
    GetMouseManager()->AddView (iIdTestView, _T("Test view"), IDR_VIEW);

   
// Initialize context menus:
    GetContextMenuManager()->AddMenu (_T("Test menu"), idMenu); 
}

·                            把框架文件中的基类CMDIFrameWnd 改为 CBCGPMDIFrameWnd(in case of SDI application change CFrameWnd to CBCGPFrameWnd)

·                            将子框架的基类 CMDIChildWnd 改为  CBCGPMDIChildWnd

·                             CToolbar 改为 CBCGPToolBar并且加入一个embedded menu bar 在你的CMainFrame类中:

CBCGPMenuBar    m_wndMenuBar;   // New menu bar
CBCGToolBar      m_wndToolBar;     // Application toolbar

·                            CMainFrame::OnCreate()方法中加入下面几行以实现菜单的功能:

// Create menu bar (replaces the standard menu):
if (!m_wndMenuBar.Create (this))
{
      TRACE0("Failed to create menubar\n");
      return -1;     
// fail to create
}

m_wndMenuBar.SetBarStyle (m_wndMenuBar.GetBarStyle() |
                                          CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

·                            加入以下代码以实现ca:

m_wndMenuBar.EnableDocking (CBRS_ALIGN_ANY);
DockControlBar (&m_wndMenuBar);

Important:在你的应用程序中,你可以使用多个CBCGPToolBar .所用工具条的图像将自动合并到一张位图上 .但是只有一个CBCGPMenuBar 对象可以使用.
 

为了具有自定义工具条和菜单条, 请做如下改变:

·                            加入 toolbar/menucustomization command (for example, View| Customize...)

·                            Implement OnViewCustomize method. The codewill look something like this:

void CMainFrame::OnViewCustomize()
{
 // Create a customize toolbars dialog:
 CBCGPToolbarCustomize* pDlgCust = new CBCGToolbarCustomize (this,
TRUE
);

 // Add predefined toolbars:
 pDlgCust->AddToolBar ("Main", IDR_MAINFRAME);
 ....

 // Add user-defined commands:
 pDlgCust->AddButton ("User", CBCGPToolbarButton (ID_USER_TOOL1, 1, "User Tool 1", TRUE));
 pDlgCust->AddButton ("User", CBCGToolbarButton (ID_USER_TOOL2, 2, "User Tool 2", TRUE));
 pDlgCust->AddButton ("User", CBCGToolbarButton (ID_USER_TOOL3, 3, "User Tool 3", TRUE));
 ....

 pDlgCust->SetUserCategory ("User");

 // Enable Create/Delete of the user-defined toolbars:
 pDlgCust->EnableUserDefinedToolbars ();

 pDlgCust->Create ();
}

为了能具有 MicrosofteOffice 2000 的菜单风格:

·                            Define your own basic commands set (usuallyin CMainFrame::OnCreate()):

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::EnableMenuShadows (BOOL bEnable = TRUE)

Note: pleasedon't use menu shadows if your views content may be dynamically changed whenthe popup menu is shown (e.g., views shows animation, HTML page). In this casemenu shadow "is remember" the previous view image.

在运行时改变菜单的字体:

CBCGPMenuBar::SetMenuFont (LPLOGFONT lpLogFont, BOOL bHorz = TRUE);

使工具条具有"pager"(customization) button just call:

m_wndToolBar.EnableCustomizeButton (TRUE, id_of_customize_command,
_T("Customize..."));

使工具条的按钮下具有文字:

m_wndToolBar.EnableTextLabels (BOOL bEnable = TRUE);

使用户能自定义工具:

·                            Add a new menu item: ID_TOOLS_ENTRY. Thisitem will be automatically replaced by the actual tools list

·                            Add the following items to the STRINGresource:
 

1.                                                   ID_TOOL1    "Activatesuser-defined tool\nUser Tool"

2.                                                   ID_TOOL2    "Activatesuser-defined tool\nUser Tool"
....

3.                                                   ID_TOOLx    "Activatesuser-defined tool\nUser Tool"
 

·                            In application's InitInstance() call:
 

EnableUserTools (ID_TOOLS_ENTRY, ID_TOOL1,    ID_TOOLx);

·                            A new "Tools" page will be addedto the customization dialog

To enable dynamic"tear-off" ("detachable") menus:

·                            Reserve some items in the STRING resourcetable. These IDs will be used as control bars IDs

1.                                                   ID_TEAR_OFF1   "<dummy>"

2.                                                   ID_TEAR_OFF2   "<dummy>"

3.                                                   .......

4.                                                   ID_TEAR_OFFx   "<dummy>"

·                            For each "tear-off" popup menu,change the "Break" property to "Bar" (MF_MENUBARBREAK)

·                            In application's InitInstance() call: 

EnableTearOffMenus (_T("RegBase", ID_TEAR_OFF1, ID_TEAR_OFFx);

To enable static"tear-off" ("detachable") menus:

·                            Reserve an item in the STRING resourcetable. This ID should be differ from dynamic tear-off ID (see above)
ID_TEAR_OFF_BAR    "<dummy>"
 

·                            In the main frame OnShowPopupMenu, enable"tear-off" for the specific menu button:
 

pMenuButton->SetTearOff (ID_TEAR_OFF_BAR);

To ensure, that allBCGPControlBar allocations are freed properly:

·                            Add the following call into yourapplication's ExitInstance() :

::BCGCBProCleanUp ();

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
BCGControlBarPro.v12.00完整源代码(含资源汉化帮助文件和VS2008文向导)第三部分 使用方法: 1、解压至C:\Program Files目录下(密码:xiaoqing); 2、双击导入注册表C:\Program Files\BCGSoft\BCGControlBarPro\bcgcontrolbarpro.12.00.reg; 3、运行向导C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBProIntegrationWizard.exe。 与其它不同之处: 1、包含完整的源代码、帮助文件; 2、已经对 BCGPAppWizard2005 的向导进行汉化,在 Visual Studio 2008 可使用文向导 BCGPAppWizard (参考 Visual Studio 2008 原有的文向导,如果您想学习汉化向导,参考目录是:C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\MFC\Application\templates\2052) 关于静态链接: 1、首先必须在运行向导BCGCBProIntegrationWizard.exe时已经编译静态; 2、在 Visual Studio 建立项目向导时,选择静态链接即可。 关于使用 Office2007、2010 风格: 如果您使用了这些新风格,必须在项目包括这些资源,否则 debug 版本启动时会报错(缺少资源,release版本不会提示,但显示不正常),具体有二种方法: 1、直接在“解决方案资源管理器”-“资源文件”点右键,“添加”-“现有项”,把C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles所有扩展名为 .rc 的资源包括进来即可。 2、直接在“资源视图”-“您的项目”上点右键,选择“资源包括”,在“资源包括”的“编译时指令”的#include "BCGCBPro.rc"后面添加以下代码: #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Aqua.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Luna.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Obsidian.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Silver.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2010White.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleCarbon.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleScenic.rc" 3、如果使用动态链接,请手工编译C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\Office2007_styles.sln或者build_all.dsp 仅为学习使用,下载后24小时内删除,请支持 BCGSoft 购买正版,本人不提供技术支持,不对任何负责。 尊重他人劳动成果,欢迎与大家分享成果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值