|
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:
If you're using evaluation version:
The library include files are located in <install dir>\BCGCBPro
directory. (The default installation folder is "c:\program
files\bcgsoft\BCGControlBar Professional Evaluation"). The library
project files prepared for Visual C++ 6.0, Visual Studio.NET, Visual Studio.NET
2003 and Visual Studio 2005/2008 are located in <install dir>\Bin directory. The
following convention is used for library/DLL names:
BCGCBPROmmmEvalnn,
where 'mmm' - BCGControlBar Library version and 'nn'
- Visual Studio version. For example, if you downloaded BCGControlBar Pro
version 20.0, the following binary files are shipped:
|
BCGCBPRO200Eval60.dll |
Visual C++ 6.0 DLL |
|
BCGCBPRO200Eval60.lib |
Visual C++ 6.0 Library |
|
BCGCBPRO200Eval70.dll |
Visual Studio.NET DLL |
|
BCGCBPRO200Eval70.lib |
Visual Studio.NET Library |
|
BCGCBPRO200Eval71.dll |
Visual Studio.NET 2003 DLL |
|
BCGCBPRO200Eval71.lib |
Visual Studio.NET 2003 Library |
|
BCGCBPRO200Eval800.dll |
Visual Studio 2005 DLL |
|
BCGCBPRO200Eval800.lib |
Visual Studio 2005 Library |
|
BCGCBPRO200Eval900.dll |
Visual Studio 2008 DLL |
|
BCGCBPRO200Eval900.lib |
Visual Studio 2008 Library |
The library files are located in <install dir>\Bin and for your convenience
the above DLLs are placed into Windows System32 directory.
If you're using retail version:
You should build all
BCGControlBar DLLs. We recommend to use our BCGCBProBuildWizard application
(located in the installation root). Or, alternatively, you can open
BCGCBPro project in your Visual Studio environment and and build all required
configurations. You will get following DLLs and library files:
| BCGCBPRO***Dxx.dll,
BCGCBPRO***Dxx.lib |
DLL debug version |
| BCGCBPRO***xx.dll,
BCGCBPRO***xx.lib |
DLL release version |
| BCGCBPRO***UDxx.dll,
BCGCBPRO***UDxx.lib |
DLL debug version, UNICODE |
| BCGCBPRO***Uxx.dll,
BCGCBPRO***Uxx.lib |
DLL release version UNICODE |
| BCGCBPRO***StaticDxx.lib |
static library debug version |
| BCGCBPRO***StaticDSxx.lib |
static library debug version, MFC
shared DLL |
| BCGCBPRO***Staticxx.lib |
static library release
version |
| BCGCBPRO***StaticSxx.lib |
static library release version, MFC
shared DLL |
| BCGCBPRO***StaticUDxx.lib |
static library debug version,
UNICODE |
| BCGCBPRO***StaticUDSxx.lib |
static library debug version, UNICODE,
MFC shared DLL |
| BCGCBPRO***Uxx.lib |
static library release version,
UNICODE |
| BCGCBPRO***USxx.lib |
static library release version,
UNICODE, MFC shared DLL |
*** means version number and xx means Visual Studio version (empty for Visual
C++ 6.0). For example, if you are
using library version 20.0 and build DLLs using Visual Studio 2012, release version of DLL will be
BCGCBPRO200110.dll
All these files will be located in your
<BCGLibrary Directory>\Bin directory (default location is "c:\Program
Files\BCGSoft\BCGControlBarPro\Bin").
Important: 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 "New Project...." dialog
and choose BCGPAppWizard. 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/VS 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 guide you
through the basic steps that you should make:
- Add #include
"BCGCBProInc.h" to your stdafx.h. The project
will be linked with the appropriated BCGControlBarlibrary
automatically.
- Add CBCGPWorkspace-derivation to your application class:
class CMyApp : public CWinApp, public CBCGPWorkspace
- Make sure, that you call AfxOleInit() in your application
InitInstance()
- Add the following call to InitInstance():
SetRegistryKey(_T("MyCompany\\MyProduct"));
- Call BCGCBProCleanUp() in you application's
ExitInstance() method.
- Change CMainFrame base class:
- SDI application: replace CFrameWnd with
CBCGPFrameWnd
- MDI application: replace CMDIFrameWnd with CBCGPMDIFrameWnd
and CMDIChildWnd to CBCGPMDIChildWnd
- Replace COleIPFrameWnd with
CBCGPOleIPFrameWnd
(Important: please make these change everywhere,
not in the class declaration only!)
- Change CToolBar to CBCGPToolBar. Please note, if
you are calling CToolBar method SetSizes with different values for several toolbars, it doesn't work! CBCGPToolBar:: 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: CBCGPMenuBar m_wndMenuBar and initialize
it in the same way as the toolbar
member (see example code).
- Set the application visual style at the beginning of your CMainFrame::OnCreate():
CBCGPVisualManager::SetDefaultManager(RUNTIME_CLASS(manager));
where the manager is one of:
- CBCGPVisualManager - MS Office 2000 look
- CBCGPVisualManagerXP - MS Office XP look
- CBCGPVisualManager2003 - MS Office 2003 look
- CBCGPVisualManager2007 - MS Office 2007 look
- CBCGPVisualManagerVS2005 - Visual Studio 2005 look
- CBCGPVisualManagerVS2008 - Visual Studio 2008 look
- CBCGPVisualManager2010 - MS Office 2010 look
- CBCGPVisualManagerVS2010 - Visual Studio 2010 look
- CBCGPVisualManagerVS2012 - Visual Studio 2012 look
- CBCGPVisualManager2013 - MS Office 2013 look
- CBCGPWinXPVisualManager - Windows native look.
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 (CBCGPPopupMenu* 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: CBCGPToolbarMenuButton 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.
In addition, BCGControlBar Library
automatically updates toolbar and menu resources. To enable this feature, you
need to pass TRUE to CBCGPWorkspace constructor:
| Example: |
CMyApp::CMyApp() :
CBCGPWorkspace (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 CBCGPToolBar::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 CBCGPMenuBar::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:
- Build a static library (see first question).
- 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/2005/2008).
- Add #include "bcgprores.h" to "Read-only symbol directives".
- Add #include "BCGCBPro.rc" to "compile-time directives".
(if your project requires localization, type #include "L.***\bcgcbpro.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 _BCGCBPRO_STATIC_ to "compile-time directives".
If you need to load Office 2007-like styles, you've to add the following .rc
files to "compile-time directives" after #include "BCGCBPro.rc":
#include "<BCGPro installation folder>\Styles\BCGPStyle2007Luna.rc"
#include "<BCGPro installation folder>\Styles\BCGPStyle2007Obsidian.rc"
#include "<BCGPro installation folder>\Styles\BCGPStyle2007Silver.rc"
#include "<BCGPro installation folder>\Styles\BCGPStyle2007Aqua.rc"
and add <BCGPro installation folder>\Styles
folder to "Additional resource include directory" in the project's Resources
settings.
|
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 BCGPIE7Demo example).
Back to top
Q: I put a
tree control into CBCGPDockingControlBar 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 CBCGPToolBar in dialog
boxes?
A: Yes. To do so, you
need to add CBCGPToolBar 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
Q:
In my application I have a number of toolbars. How to create
one of the toolbars with a different image/button size?
A: By design, all buttons in the customizable toolbars
should have the same image size. Otherwise, it will be
impossible to move a button from one toolbar to another.
However, if you need a toolbar with either larger/smaller
images, you need to create it as "locked" (non
customizable). To do it, just set bLocked parameter of CBCGPToolBar::LoadToolBar to TRUE:
| Example: |
void
CMainFrame::OnCreate (LPCREATESTRUCT lpCreateStruct) {
....
m_wndToolBar.LoadToolBar (IDR_MAINFRAME);
m_wndToolBar2.LoadToolBar (ID_OF_LARGE_TOOLBAR, 0, 0, TRUE
/* bLocked */);
.... } |
Back to top
Q:
I'm porting my application to BCGControlBar. When I'm trying
to access the main application menu, GetMenu always
returns NULL. How can I change my menu bar?
A: Because BCGControlBar's menu bar (CBCGPMenuBar)
replaces the standard application menu, GetMenu always
returns NULL. We suggest you the following ways to
manipulate your menu at run time:
- Don't call EnableMenuItem or CheckMenuItem: use the OnUpdateCommand
mechanism instead
- If you need to change popup menu content (such as "File" or "Help"
menus) dynamically, override the OnShowPopupMenu method in your
CMainFrame class (see DynamicMenu sample application).
- If you need to change top-level menu items, derive your class
from CBCGPMenuBar and override the RestoreOriginalstate method (see DynamicMenu
sample application).
| Example: |
BOOL CMainFrame::OnShowPopupMenu (CBCGPPopupMenu*
pMenuPopup) {
// Remove first menu item:
pMenuPopup->RemoveItem (0);
// Insert new menu item:
pMenuPopup->InsertItem (CBCGPToolbarMenuButton (id,
NULL, -1, _T("MyItem 1")), 1);
.... }
BOOL CMyMenuBar::RestoreOriginalstate ()
{
CBCGPMenuBar::RestoreOriginalstate ();
// Insert new menu item:
CMenu menu;
menu.LoadMenu (IDR_DYNAMIC_MENU);
InsertButton (CBCGPToolbarMenuButton (0, menu, -1, _T ("&DynamicMenu")));
AdjustLayout();
AdjustSizeImmediate ();
.... } |
Back to topQ:
When I'm trying to link my program with BCGControlBar library, I get lot
of linker errors like 'error LNK2001: unresolved external symbol "public:
virtual long __thiscall CBCGPWnd::get_accName'. How can I resolve this problem?
A: If you get the following error messages:
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accName
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accValue
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accDescription
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accHelp
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accHelpTopic
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accKeyboardShortcut
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::get_accDefaultAction
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::put_accName
- error LNK2001: unresolved external symbol "public: virtual long __thiscall
CBCGPWnd::put_accValue
please check the option "Treat wchar_t as built in type" in C/C++ |
Language settings for the project and change it to the opposite. The point
is that the project should be compiled with the same setting as the library.
Back to top
|