Solved

Creating toolbars with > 256 colors

Posted on 1998-02-06
4
857 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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