Click here to Skip to main content
15,867,686 members
Articles / Desktop Programming / MFC
Article

VC6 flat toolbar support

Rate me:
Please Sign up or sign in to vote.
3.50/5 (4 votes)
9 Nov 2000 81.3K   20   2
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 you project to reduce size.

Introduction

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. Obviously there were slight changes applied to MFC.

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 
<font color="#008000">        // do the VC 5.0 stuff
</font>#else
<font color="#008000">        // do the really cool VC6.0 stuff
</font>#endif 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
PhD Chemist,
programming with MSVC & MFC since 1996

Comments and Discussions

 
GeneralUnhandled exception when using flat style Pin
10-Nov-00 8:39
suss10-Nov-00 8:39 
GeneralRe: Unhandled exception when using flat style Pin
12-Dec-00 0:23
suss12-Dec-00 0:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.