Solved

Creating toolbars with > 256 colors

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now