Sample: Fix2lBar.exe Fixes Spacing Errors in MFC's CToolBarID: Q195081
|
Fix2lBar.exe is a sample that show how to correct CToolBar's behavior. The
original CToolBar, relying only on early releases of the common controls,
does not behave intuitively whenever it contains two or more consecutive
separators and it has vertical orientation. This behavior is even more
striking when the toolbar has the new TBSTYLE_FLAT style.
This sample provides a CToolBar-derived class that takes advantage of the
new common controls features, in particular, of the CCS_VERT style, now
available for control bars. Building on the new features of the toolbar
control, the new class overrides the necessary functions to provide the
correct behavior. The class requires ComCtl32.DLL versions 4.72 or greater.
The following file is available for download from the Microsoft Software Library:
~ Fix2lBar.exeRelease Date: Oct-30-1998
Q119591 How to Obtain Microsoft Support Files from Online Services
File Name Size
---------------------------------------------------------
FixToolBar.h, The new CFixToolBar class that overrides
FixToolBar.cpp necessary methods in CtoolBar.
FixTBar.dsp The project file.
FixTBar.h The main header file for the application.
FixTBar.cpp The main application source file (CFixTBarApp).
FixTBar.rc Listing of all Windows resources used.
res\FixTBar.ico Icon file, which is used as the application's icon.
res\FixTBar.rc2 Resources that are not edited by Visual C++ IDE.
MainFrm.h,
MainFrm.cpp Contain the frame class CMainFrame.
res\Toolbar.bmp Used to create tiled images for the toolbar.
FixTBarDoc.h,
FixTBarDoc.cpp The document CFixTBar class.
FixTBarView.h
FixTBarView.cpp The view of the document CFixTBarView class.
StdAfx.h
StdAfx.cpp Used to build a precompiled header (PCH) file.
Resource.h Defines new resource IDs.
The sample contains an AppWizard-generated SDI application, and implements
a CToolBar-derived class that implements the necessary fixes. The solution
relies basically on adding the new style CCS_VERT to the toolbar when it
must display more than just one row of buttons. In addition, the CalcSize()
and WrapToolBar() functions must be overridden. However, because these two
functions are not virtual, all CToolBar members that call these two
functions need to be copied and pasted in the new class, up to and
including the virtual functions CalcFixedLayout() and CalcDynamicLayout().
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
BEGIN
BUTTON ID_FILE_NEW
BUTTON ID_FILE_OPEN
BUTTON ID_FILE_SAVE
SEPARATOR
SEPARATOR
BUTTON ID_EDIT_CUT
BUTTON ID_EDIT_COPY
BUTTON ID_EDIT_PASTE
SEPARATOR
BUTTON ID_FILE_PRINT
SEPARATOR
BUTTON ID_APP_ABOUT
END
You can experiment with both flat style toolbars and old style toolbars. To
do this, comment in and out the corresponding toolbar creation code in
CMainFrame::OnCreate().
Additional query words: kbDSupport
Keywords : kbfile kbMFC KbUIDesign kbVC600
Version : WINNT:6.0
Platform : winnt
Issue type :
Last Reviewed: August 5, 1999