Porting from MSVC 5.0 to vers. 6.0
and getting that cool flat toolbar
When you are porting your MFC application to MSVC 6.0 you'd probably like to
use the build-in support for the flat toolbar and kick that third-party
solution out of your project reducing the file size.
If you download a cool sample application and give it a try in your MSVC
5.0 environment, you may have a problem when compiling it, because your
compiler doesn't know the CToolBar::CreateEx method which is new in the
MFC since MSVC 6.0 was released.
In order to do this, you simply have to change a few lines of source code.
This is what the 5.0 application wizard wrote for you in in CMainFrame::OnCreate:
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
change this to
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
and this could be all, if you don't need to support both compilers. If you want to give
your source code away to your friends who still have the older version, you may use the
poor documented preprocessor constant _MSC_VER:
#if _MSC_VER > 1100 // for MSSVC 5.0 this is 1100
// do the VC 5.0 stuff
#else
// do the really cool VC6.0 stuff
#endif
|