Toolbar with 16M colour images | CodeGuru

Toolbar with 16M colour images

Download Source Code and Example  66KB I tried Kevin Bentley’s trick to use 256 colours but it didn’t work. I needed to have more than 256 colours – so I tried to find some alternative way – fortunately I found it. Here’s how can you use hi-color bitmaps on your toolbars: At first, create your […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 22, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Download Source Code and Example  66KB

I tried Kevin Bentley’s trick to use 256 colours but it didn’t work.
I needed to have more than 256 colours – so I tried to find some alternative way –
fortunately I found it.

Here’s how can you use hi-color bitmaps on your toolbars:

At first, create your toolbar in Developer Studio – no matter what do you draw on
buttons. Make a hi-color bitmap with a bitmap-editor (for example Paint Shop Pro). This
new bitmap must be the same size as Toolbar.bmp in your project’s \res folder. Then import
the resource into your application as bitmap, name it IDB_TOOLBARHI. Here’s what you must
to do:

  • Make a CBitmap type global variable m_bmToolbarHi in your CMainFrame class
  • Include these lines in the function CMainFrame::OnCreate() after initializing the
    toolbar:
    if (!m_wndToolBar.Create(this) ||
        !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1; // fail to create
    }

// ===========================================================
    m_bmToolbarHi.LoadBitmap( IDB_TOOLBARHI );
    m_wndToolBar.SetBitmap( (HBITMAP)m_bmToolbarHi );
// ===========================================================
  • Include this line in the destructor of CMainFrame:
CMainFrame::~CMainFrame()
{
// ===========================================================
    m_bmToolbarHi.DeleteObject();
// ===========================================================
}

That’s all.

Last updated: 16 July 1998

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.