Solved

Creating toolbars with > 256 colors

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 63
iSeries DB2 Query 2 95
difference between String.subString() and String.subSequence() 6 200
fizzArray  challenge 1 84
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 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