[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating toolbars with > 256 colors

Posted on 1998-02-06
4
Medium Priority
?
861 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 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

831 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