Click here to Skip to main content
12,504,002 members (54,987 online)
Click here to Skip to main content
Add your own
alternative version

Stats

74.7K views
20 bookmarked
Posted

VC6 flat toolbar support

, 9 Nov 2000
Rate this:
Please Sign up or sign in to vote.
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.
<!-- Main HTML starts here -->

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>

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

Share

About the Author

Thomas Blenkers
Web Developer
Germany Germany
PhD Chemist,
programming with MSVC & MFC since 1996

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralUnhandled exception when using flat style Pin
Brad10-Nov-00 8:39
memberBrad10-Nov-00 8:39 
GeneralRe: Unhandled exception when using flat style Pin
Serrand12-Dec-00 0:23
memberSerrand12-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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 10 Nov 2000
Article Copyright 2000 by Thomas Blenkers
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid