Solved

Creating toolbars with > 256 colors

Posted on 1998-02-06
4
856 Views
Last Modified: 2013-11-19
What is the easiest way to create toolbars with greater than 256 color buttons?  When I'm in the Developer Studio and I copy in a high color bitmap from MS Photo editor, it appears just fine on the toolbar I'm creating until I click File/Save.  Then it changes to a 256 color representation.  When I bring up the bitmap that represents the toolbar in MS Photo Editor, the properties show that it is a 256 color bitmap.  If I resave it to a 24 bit color bitmap, Dev Studio no longer can read it. If I compile and run, the buttons are black.  
0
Comment
Question by:skin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:skin
ID: 1315694
In fact I have not been able to use anything above 16 color.
0
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1315695
Standard tool bar doesn't support more then 256 colors. To create toolbar with more then 256 colors you must handle WM_PAINT message, i.e. override OnPaint function in your CToolBar derived class and implement your custom painting using DIB functions. By the way if you copy and paste bitmap <= 256 colors from other graphics application you should save also palette in temporary palette file and then load it in VC++. Only then you should paste bitmap from the clipboard.
0
 

Expert Comment

by:vypress
ID: 1315696
well, well...
but at www.codeguru.com/toolbar/ there is an example, how to put 256 color bitmap on toolbar. Simple use LoadBitmap(..) function...
0
 

Author Comment

by:skin
ID: 1315697
vypress,

I followed these instructions from the page you pointed me to:
-----------------------------------------------------------
I recently needed to have 256 color toolbars in my app. If you create 256 color bitmaps in devstudio, and try to use them with CToolbar it won't work.
The problem is in the LoadBitmap() member or CToolbar. Appwizard will create the following line in your CMainFrame class:
m_wndToolBar.LoadBitmap(IDR_MAINFRAME)
Here is the fix, just replace the load bitmap call with a call to the control itself:
m_wndToolBar.GetToolBarCtrl().AddBitmap(iNumButtons,IDR_MAINFRAME);
It really is that easy, I found this solution after writing my own toolbar class that used the tool control directly, and 256 color bitmaps worked fine. I couldn't believe it, but it works!
-----------------------------------------------------------
But, first, there wasn't a statement like this
m_wndToolBar.LoadBitmap(IDR_MAINFRAME)
in my CMainFrame class.  So I tried creating an MDI app from scratch and did not find one either.

Thanks for any help you can provide.


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question