Remark: this article assumes that you are familiar with MFC and Microsoft® Visual C++® environment.
Q: I've installed BCGControlBar library, but I can't find any DLLs and library files. Where can I find them? A: You should build all BCGControlBar DLLs. Open BCGControlBar project and make all required configurations. You will get following DLLs and library files:
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* |
*** means version number. For example, if you are using library version 5.51, release version of DLL will be BCGCB551.dll * static library version with MFC shared DLL available for the version 4.7 or later All these files will be located in your <BCGLibrary Directory>/Bin directory. Please remember add this directory to the system path. Back to top Q: How can I start using BCGControlBar library? A: First of all, build all BCGControlBar libraries (see question above). Then open BCGAppWizard project and build it. Now if you open "New Project...." dialog, a new entry will appear. This application wizard is very similar to the standard MFC's AppWizard. On the last step this wizard allows you to define BCGControlBar-specific items. Finish the wizard and build your project. Run it and you will see how simple it is to create MS-Office look-and-feel applications! Back to top Q: How can I switch my existing MFC application to BCGControlBar library? A: First of all, BCGControlBar library doesn't replace MFC, it just enhances it. So unless you have in use some tricky methods (such as subclassing MDI client area window), this process should be easy. Here we'll try to guilde you through the basic steps that you should make:
- Add #include
"bcgcb.h" ("BCGCBProInc.h" in case of Professional Edition) to your stdafx.h. The project will be linked with the appropriated BCGControlBar*** library automatically.
- Change CMainFrame base class:
- SDI application: replace CFrameWnd to CBCGFrameWnd (
CBCGPFrameWnd in Professional Edition)
- MDI application: replace CMDIFrameWnd to CBCGMDIFrameWnd; CMDIChildWnd to CBCGMDIChildWnd (
CBCGPMDIFrameWnd and
CBCGPMDIChildWnd in Professional Edition)
- replace COleIPFrameWnd to CBCGOleIPFrameWnd (
CBCGPOleIPFrameWnd in Professional Edition)
(Important: please make these change everywhere, not in the class declaration only!) - Change CToolBar to CBCGToolBar (CBCGPToolBar in Professional Edition). Please note, if you are calling CToolBar method SetSizes with different values for several toolbars, it doesn't work! CBCGToolBar:: SetSizes is a static method because all toolbar's buttons have to have the same size.
- If you would like to add a menu bar (MS Office-like dockable control bar with a menu), just add the following member to CMainFrame class:
CBCGMenuBar m_wndMenuBar (CBCGPMenuBar in Professional Edition) and initialize it in the same way as the toolbar member (see example code). Back to top Q: How can I change the menu contents dynamically, in run-time? A: Override CBCG***FrameWnd::OnShowPopupMenu method.
Example: | BOOL CMainFrame::OnShowPopupMenu (CBCGPopupMenu* pPopupMenu) { BOOL bRes = CBCG***FrameWnd::OnShowPopupMenu (pPopupMenu);
if (pPopupMenu != NULL) { // Remove item number 3 from menu pPopupMenu->RemoveItem (3);
// Insert item with id ID_VIEW_TOOLBAR into the 2-nd position: CBCGToolbarMenuButton btnNewMenuItem (ID_VIEW_TOOLBAR, NULL, -1); pPopupMenu->InsertItem (btnNewMenuItem, 2); }
return bRes; } |
Back to top Q: I added some new toolbar buttons and menu items in my Resource Editor, but I don't see them when I'm running the application. What's going wrong? A: BCGControlBar library loads toolbar and menu items directly from the resources when you are running the program for the first time. Next time, library will retrieve the data from the registry, where all customization results were saved. To see your changes, just open customization dialog, switch to the "Toolbars" page and click "Reset All" button. Customization manager will reset all toolbars and menu states. Starting version 5.4, BCGControlBar Library automatically updates toolbar and menu resources. To enable this feature, you need to pass TRUE to CBCGWorkspace constructor:
Example: | CMyApp::CMyApp() : CBCGWorkspace (TRUE /* bResourceSmartUpdate */) { } |
Back to top Q: I would like assigning some images to the menu items without placing them on the toolbars. Is it possible? A: Yes! In the Resource Editor, create a new toolbar (e.g. IDR_MENUIMAGES). Add a new buttons associated with a menu commands. Now, in CMainFrame::OnCreate just call CBCGToolBar::AddToolBarForImageCollection (IDR_MENUIMAGES) (static function). Back to top Q: How can I add to my program context menus? A: In the Resource Editor, create a new menu resource (e.g. IDR_MYMENU). If this menu needs to be customizable, add it to your context menu customization manager (CMyApp::PreLoadState ()):
Example: | void CMyApp::PreLoadState() { ... AddMenu (_T("Menu Name"), IDR_MY_MENU); } |
Add WM_CONTEXTMENU handler to your CWnd/CView- derived class:
Example: | void CMyView::OnContextMenu(CWnd*, CPoint point) { theApp.ShowPopupMenu (IDR_MY_MENU, point.x, point.y, this) } |
Back to top Q: Is it possible to change a default menu font? A: Yes. Just call static function BOOL CBCGMenuBar::SetMenuFont (LPLOGFONT lpLogFont, BOOL bHorz = TRUE); Back to top Q: How can I add a library to my static MFC project? A: You need to follow these steps:
- Open BCGControlBarStatic workspace and build a static library.
- In the Visual C++® open "Resource Includes" dialog (View | Resource Includes in Visual C++
® 6.0 or right click to .rc folder in "Resource View " tab in Visual Studio.NET
®).
- Add #include "bcgbarres.h" to "Read-only symbol directives".
- Add #include "bcgcontrolbar.rc" to "compile-time directives". (#include "BCGCBPro.rc" for Professional Edition).
(if your project requires localization, type #include "L.***/bcgcontrolbar.rc" where *** is a language name prefix. See Localization page for more details) - Remove _AFX_NO_SPLITTER_RESOURCES. Otherwise, you'll not be able to see splitter cursors required by the library.
- If you are using static library version with MFC shared DLL, add
"#define _BCGCONTROLBAR_STATIC_" (_BCGCBPRO_STATIC_ for Professional Edition) to "compile-time directives". | ![](https://i-blog.csdnimg.cn/blog_migrate/03973ce6cb42689888fedaa11db80c33.gif) | Back to top Q: I would like to draw my own images on the menu items without adding them to toolbars resources. How can I do it? A: Override CBCG***Frame::OnDrawMenuImage () function (see BCGIEDemo example). Back to top Q: I put a tree control into CBCGSizingControlBar tab window. How can I response the messages of the tree control? A: Create your own tree control class derived from CTreeCtrl and add a message handler(s) to this class. Back to top Q: I create two toolbars in the OnCreate method of my CMainFrame class. When I run the application for the first time, the toolbars show, but when I run a second time, the toolbars are the same and look like the second toolbar. What am I doing wrong? A: Make sure that each toolbar is created with its own unique id:
Wrong (each toolbar was created with AFX_IDW_TOOLBAR ID): | void CMainFrame::OnCreate (LPCREATESTRUCT lpCreateStruct) { .... m_wndToolBar.Create (this, <style>); m_wndToolBar2.Create (this, <style>); .... } |
Correct: | void CMainFrame::OnCreate (LPCREATESTRUCT lpCreateStruct) { .... m_wndToolBar.Create (this, <style>); m_wndToolBar2.Create (this, <style>, id_of_second_toolbar); .... } |
Back to top Q: Is it possible to use CBCGToolBar in dialog boxes? A: Yes. To do so, you need to add CBCGToolBar m_wndToolBar in your dialog class and add the following code in CMyDialog::OnInitDialog:
Example: | BOOL CMyDialog::OnInitDialog() { ... m_wndToolBar.SetOwner (this /* dialog class */); m_wndToolBar.SetRouteCommandsViaFrame (FALSE); ... } |
Back to top Q: Is BCGControlBar Library available for Visual Basic® or other ActiveX container? A: No Back to top
Q: I'm using Visual C++ 6.0. I'm getting access violation in CHtmlView::Refresh2
during execution of my application
. What's going wrong? A: You need to install Visual Studio SP3 or higher. In addition, if your VC's locale differs from English, you must manually activate the setupsp3.exe in the /enu subdirectory (English version). Back to top
Q: The following error appears when I'm trying to compile the library under VC++ 6.0 + platform SDK: "transact.h(226) : error C2059: syntax error : 'constant'". How can I solve this problem? A: Make sure, that MFC's include directory is placed atop the SDK and SQL in the VC include directories list. There are some files with the same name (for example, "occimpl.h"), but with a completely different context. In VS.NET, MFC's "occimpl.h" is renamed to "afxocc.h", therefore this problem is relevant for the version 6.0 only. Back to top |