• BCGControlBar 库 使用方法



    http://xiaohonghong.blog.hexun.com/25282438_d.html


    安装 BCGControlBar 库到你的计算机:

    • 解压缩 BCGControlBar.zip (比如,到 c:\bcg 目录中)
    • 把 c:\bcg\bin 增加到你的 path 环境变量中,
    • 运行 Visual C++ 并且打开 Tools | Options 对话框,切换到Directories 页并且把 c:\bcg\bcgcontrolbar 加入到 include 目录 中,把 c:\bcg\bin 加入 library 和 executable 目录中;
    • 打开Bcgcontrolbar 和/或 BcgcontrolbarStatic 项目(路径是 c:\bcg\bcgcontrolbar) 并且选择需要的选项;
    • 如果要安装 BCGControlBar 应用程序向导,只需要打开BCGBAppWizard 项目并编译链接。你将在项目列表中看到一个新的条目。

    你必须编译链接所有的 BCGControlBar 库的 DLL 文件;

    打开 BCGControlBar 项目并编译链接。下面是一个你将得到的 DLLs 和 库文件列表:

    BCGCB***D.dll, BCGCB***D.lib DLL debug version
    BCGCB***.dll, BCGCB***.lib DLL release version
    BCGCB***UD.dll, BCGCB***UD.lib DLL debug version, UNICODE
    BCGCB***U.dll, BCGCB***U.lib DLL release version UNICODE
    BCGCB***StaticD.lib static library debug version
    BCGCB***StaticDS.lib static library debug version, MFC shared DLL*
    BCGCB***Static.lib static library release version
    BCGCB***StaticS.lib static library release version, MFC shared DLL*
    BCGCB***StaticUD.lib static library debug version, UNICODE
    BCGCB***StaticUDS.lib static library debug version, UNICODE, MFC shared DLL*
    BCGCB***U.lib static library release version, UNICODE
    BCGCB***US.lib static library release version, UNICODE, MFC shared DLL*

    *** 表示版本号。比如,如果你使用的库版本为 5.00 发行版, DLL 的相应的发行版本为 BCGCB500.dll
    * static library version with MFC shared DLL 适用于 4.7   或更高版本。

    所有这些文件将定位在你的 <BCGLibrary Directory>\Bin 目录中。 记得要把这些目录加入你的系统目录中。


    请按如下内容改变你的源代码:

    • 添加 BCGControlBar 路径到 INCLUDE 路径
    • 确定你在你的应用程序中调用 了 AfxOleInit() InitInstance()
    • 添加下列语句到 stdafx.h 文件:
    #include "BCGCB.h"
    class CMyApp : public CWinApp,
                             public CBCGWorkspace
    • 首先,你必须定义在注册表中存放你自定义数据的位置和你 需要什么样的自定义(鼠标、键盘、上下文菜单),为了做这些工作,在CMyApp::InitInstance 中设置注册表入口并初始化自定义管理器:
    SetRegistryBase (_T("Settings"));

    // 初始化自定义管理器:
    InitMouseManager();
    InitContextMenuManager();
    InitKeyboardManager();
    • 如果你已经决定使用鼠标或上下文菜单的自定义功能,你必 须在鼠标自定义管理器中附加一个视图,或初始化上下文菜单。重载CBCGWorkspace::PreLoadState 行为:
    class CMyApp ....
    {
    ...

    virtual void
     PreLoadState();
    ...
    };


    void CMyApp::PreLoadState()
    {
        
    // 把鼠 标事件连接到特定 的视图 :
         GetMouseManager()->AddView (iIdTestView, _T("
    Test view"), IDR_VIEW);

        
    // 初始化上下文菜单:
         GetContextMenuManager()->AddMenu (_T("
    Test menu"), idMenu); 
    }
    • 同时在 mainfrm.h 和 mainfrm.cpp 文件中 把 CMDIFrameWnd 变成 CBCGMDIFrameWnd ,(在 SDI 应用程序的情况下, 把 CFrameWnd 变成 CBCGFrameWnd
    • 把 CMDIChildWnd 变成  CBCGMDIChildWnd
    • 把 CToolbar 变成 CBCGToolBar 并且添加一个内嵌菜单栏对象到你的 CMainFrame 类中:
    CBCGMenuBar     m_wndMenuBar;    // 新的菜单栏
    CBCGToolBar       m_wndToolBar;      
    // 应用程序工具栏
    • 在 CMainFrame::OnCreate() 行为中添加如下的行,以便使能菜单栏功能:
    // 创建菜单栏(替换标准菜单):
    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 对象被使用。

    为了使能 工具栏/菜单 的自定义,请作出如下改变:

    • 添加 工具栏/菜单 自定义命令(比如,View | Customize...
    • 实现 OnViewCustomize 行为。代码看起来如下:
    void CMainFrame::OnViewCustomize() 
    {
    // 创建一个自定义工具栏对话框:
    CBCGToolbarCustomize* pDlgCust = new CBCGToolbarCustomize (this, 
    TRUE 
    /* Automatic menus scaning */);

    // 添加预定义工具栏:
    pDlgCust->AddToolBar ("Main", IDR_MAINFRAME);
    ....

    // 添加用户自定义命令:
    pDlgCust->AddButton ("User", CBCGToolbarButton (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");

    // 使能用户自定义工具栏的 Create/Delete :
    pDlgCust->EnableUserDefinedToolbars ();

    pDlgCust->Create ();
    }

    为了使能 Microsoft?Office 2000 菜单:

    • 定义你自己的基本命令集合(通常在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);

    CBCGToolBar::SetBasicCommands (lstBasicCoomads);

    • 这些命令将显示在下拉菜单中:

    为了使能菜单阴影:

    CBCGMenuBar::EnableMenuShadows (BOOL bEnable = TRUE)

    注意 如果你查看的内容可能动态改变就不要在弹出式菜单中使用菜单 阴影(比如,视图显示动画、HTML页)在这种情况下,菜单阴影 会记忆以前的视图图像。

    为了在运行时改变菜单字体:

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

    为了使能“页面”(自定义)按钮,只需要调用:

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

    为了使能图像覆盖下的文字:

    m_wndToolBar.EnableTextLabels (BOOL bEnable = TRUE);

    为了使能用户自定义工具:

    • 添加一个新的菜单条目:ID_TOOLS_ENTRY。该条目将 自动被实际存在的工具列表取代。
    • 添加如下的条目到 STRING 资源:
      1. ID_TOOL1     "Activates user-defined tool\nUser Tool"
      2. ID_TOOL2     "Activates user-defined tool\nUser Tool"
        ....
      3. ID_TOOLx     "Activates user-defined tool\nUser Tool"
    • 在应用程序的InitInstance() 中调用:
      EnableUserTools (ID_TOOLS_ENTRY, ID_TOOL1,     ID_TOOLx);
    • 一个 "Tools" 新页面将加入到自定义对话框中

    为了使能动态可裁剪菜单:

    • 在 STRING 资源表中保留部分条目。这些标识符将被当作控制栏标识符使用。
      1. ID_TEAR_OFF1     "<dummy>"
      2. ID_TEAR_OFF2     "<dummy>"
      3. .......
      4. ID_TEAR_OFFx     "<dummy>"
    • 对于每一个可裁剪弹出式菜单,把 "Break" 属性改位 "Bar" (MF_MENUBARBREAK)
    • 在应用程序的 InitInstance() 中调用:
      EnableTearOffMenus (_T("RegBase", ID_TEAR_OFF1ID_TEAR_OFFx);

    为了使能静态可裁剪菜单

    • 在 STRING 资源表中保留一个条目。这个标识符将区别于动态 可裁剪 标识符(如上所述)。

      ID_TEAR_OFF_BAR     "<dummy>"
    • 在主框架的 OnShowPopupMenu,为特定的菜单按钮使能可裁剪:
      pMenuButton->SetTearOff (D_TEAR_OFF_BAR);

    BCGControlBar9.0的注册密码:6CA746D4-8A7B-4373-B550-18F56C26D785

  • 相关阅读:
    html抽取文本信息-java版(适合lucene建立索引)
    【LeetCode with Python】 Sort List
    POJ 2533 Longest Ordered Subsequence(dp LIS)
    Activity 之间 传递 List 封装的对象或者对象
    mongo数据库--非关系型数据库
    cocos2d-x的声音控制
    CSDN博客积分规则
    怎样使用递归实现归并排序
    android中9-patch图片的使用
    Cocos2d-x-3.0环境搭建
  • 原文地址:https://www.cnblogs.com/gdutbean/p/2378236.html
Copyright © 2020-2023  润新知