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 shoshould build all bcgcontrolbar DLLs. Open bcgcontrolbar project and make all required comprehenations. 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>/binDirectory. 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 openBcgappwizardProject 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 shocould be easy. here we'll try to guilde you through the basic steps that you shoshould 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 wowould 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: bcgcontrolbarLibrary 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 mizmization 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 wowould 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, 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:
- OpenBcgcontrolbarstaticWorkspace and build a static library.
- In the Visual C ++ open "resource operated des" dialog (View | resource operated des 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 ctictives ".
- 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 ".
|
|
Back to Top Q: I wocould 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 fromCtreectrlAnd 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 (maid) { .... M_wndtoolbar.create (this, <style> ); M_wndtoolbar2.create (this, <style> ); .... } |
Correct: |
Void cmainframe: oncreate (maid) { .... 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. net, MFC's "occimpl. H "is renamed to" afxocc. H ", therefore this problem is relevant for the version 6.0 only. Back to Top |