在已经建好的工程项目中需要添加BCG功能!
2007-08-16 11:16
405 查看
Getting Started
BCGControlBar Library Professional Edition installation:整个库的源代码安装在<install dir>/BCGCBPro 目录下面.可执行文件(*.dll)安装在 <install dir>/Bin (for VisualStudio 6.0) 或<install dir>/Bin7 (for VisualStudio .NET)下面。
请在你的源代码中做如下的改变:
在应用程序的Include路径中加入BCGCBPro目录,具体添加办法如下:vs2005下面打开菜单工具的Option项,选择项目解决方案-〉vc++目录,然后将包含文件<install dir>/BCGCBPro 添加进去。
确信在你的应用程序的 InitInstance() 方法中调用了AfxOleInit() 。
在stdafx.h中加入下面的包含文件:
#include "BCGCBProInc.h" |
class CMyApp : public CWinApp, public CBCGPWorkspace |
SetRegistryBase (_T("Settings")); // Initialize customization managers: InitMouseManager(); InitContextMenuManager(); InitKeyboardManager(); |
class CMyApp .... { ... virtual void PreLoadState(); ... }; void CMyApp::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); } |
将子框架的基类 CMDIChildWnd 改为 CBCGPMDIChildWnd
将 CToolbar 改为 CBCGPToolBar并且加入一个embedded menu bar 在你的CMainFrame类中:
CBCGPMenuBar m_wndMenuBar; // New menu bar CBCGToolBar m_wndToolBar; // Application toolbar |
// 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); |
m_wndMenuBar.EnableDocking (CBRS_ALIGN_ANY); DockControlBar (&m_wndMenuBar); |
为了具有自定义工具条和菜单条, 请做如下改变:
加入 toolbar/menu customization command (for example, View | Customize...)
Implement OnViewCustomize method. The code will look something like this:
void CMainFrame::OnViewCustomize() { // Create a customize toolbars dialog: CBCGPToolbarCustomize* pDlgCust = new CBCGToolbarCustomize (this, TRUE /* Automatic menus scanning */); // 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 (); } |
Define your own basic commands set (usually in 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) |
在运行时改变菜单的字体:
CBCGPMenuBar::SetMenuFont (LPLOGFONT lpLogFont, BOOL bHorz = TRUE); |
m_wndToolBar.EnableCustomizeButton (TRUE, id_of_customize_command, _T("Customize...")); |
m_wndToolBar.EnableTextLabels (BOOL bEnable = TRUE); |
Add a new menu item: ID_TOOLS_ENTRY. This item will be automatically replaced by the actual tools list
Add the following items to the STRING resource:
ID_TOOL1 "Activates user-defined tool/nUser Tool"
ID_TOOL2 "Activates user-defined tool/nUser Tool"
....
ID_TOOLx "Activates user-defined tool/nUser Tool"
In application's InitInstance() call:
EnableUserTools (ID_TOOLS_ENTRY, ID_TOOL1, ID_TOOLx); |
To enable dynamic "tear-off" ("detachable") menus:
Reserve some items in the STRING resource table. These IDs will be used as control bars IDs
ID_TEAR_OFF1 "<dummy>"
ID_TEAR_OFF2 "<dummy>"
.......
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); |
Reserve an item in the STRING resource table. 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); |
Add the following call into your application's ExitInstance() :
::BCGCBProCleanUp (); |
For more information see "Some tips how to customize the application behavior"in the Library Architecture article.
相关文章推荐
- STM32 cubeMX 前期项目未生成部分模块,后期需要添加功能模块时出现L6218E错误问题的解决方法
- 为已经存在的本地项目添加git,以及从远程仓库拉取代码并切换远程分支
- Android项目如何集成ZXing二维码扫描功能(精简、竖屏、解决图像拉伸、工程库形式)
- 用Maven创建SSM项目需要添加的依赖
- MyEclipse 打开workspace已经存在的project(或工程、项目)
- SQL2000系统表、存储过程、函数的功能介绍及应用2009年01月21日 星期三 11:38虽然使用系统存储过程、系统函数与信息架构视图已经可以为我们提供了相当丰富的元数据信息,但是对于某些特殊的元数据信息,我们仍然需要直接对系统表进行查询。因为SQL
- MFC在添加gsoap生成的源文件到工程项目中,出现bug: MFC apps must not #include <windows.h>
- iOS项目工程添加.a文件遇到的Dsymutil Error
- iOS 建立项目过滤机制 —— 给工程添加忽略文件.gitignore
- vue项目中添加百度地图功能及解决遇到的问题详解
- WebStorm添加多个项目到当前工程目录
- 基于Server-Sent Event的简单聊天室 Web 2.0时代,即时通信已经成为必不可少的网站功能,那实现Web即时通信的机制有哪些呢?在这门项目课中我们将一一介绍。最后我们将会实现一个基于Server-Sent Event和Flask简单的在线聊天室。
- 为项目安装添加WEB调用本地应用程序功能
- 在android目录添加自己的项目工程
- 工程添加boot后需要设置----中断向量表的偏移量设置
- 转:Maven介绍(创建工程项目以及下载所需要的jar包)
- Android中已经添加权限,依然提示缺少权限,此时你需要添加动态权限
- 成为项目工程需要的高手
- 定义一个定义完整的类(是可以当作独立的产品发布,成为众多项目中的“基础工程”)。扩展+、-、*、/运算符的功能,使之能与double型数据进行运算。设Complex c; double d; c+d和
- client和server,如果server的port number已经确定,两者之间最大的TCP连接数是多少?工程上有什么需要注意的(2)