Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Toolbar's images not showing in 256 color mode

Posted on 2002-03-27
7
Medium Priority
?
489 Views
Last Modified: 2013-12-03
Hello!

Hello!

Using plain Win32 Api
...I have an app with a  toolbar with bitmap images in 256
colors indexed . The
toolbar displays well in W2K 24-bit True Color graphics mode. But when I
changed
W2k's graphics mode to 256 colors, the toolbar was created and displayed
sans the images.

How do I solve the mystery of the disappearing images?
What guidelines should I follow so bitmaps for toolbars(or any other window
using bitmaps)
will display properly?

How do I create bitmaps to display properly in all color modes? And how do I insert them into a toolbar, using CreateToolbarEx using whole bitmaps  and CreateWindowEx using imagelists?

I'll add another 100 points to the one who gives the suitable solution to the problem!

Thanks in advance!

Maimee Arai


0
Comment
Question by:RolandAZ
[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
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:robpitt
ID: 6900517
You've discovered a fundamental problem with the toolbar control. I ran into this ages ago back when supporting 256 colour displays mattered. Obviously a lot of people don't care about 256 colour users any more ... but since I know the solution here goes...

The problem lies in the fact that the toolbar doesn't select or realise a palette before drawing itself. Thus when running on a palettised display it attempts to draw using the default 16 standard colours (which usually doesn't work very well).


The solution is to subclass the toolbar control and then replace the WM_PAINT handler with something like the following:

          BeginPaint(hWnd,&ps);

          hopal=SelectPalette(ps.hdc,hPalette,TRUE);
          RealizePalette(ps.hdc);
         
          flags=PRF_CHECKVISIBLE|PRF_CLIENT;
          if (ps.fErase) flags|=PRF_ERASEBKGND;
          SendMessage(hWnd,WM_PRINT,(WPARAM)ps.hdc,flags);

          SelectPalette(ps.hdc,hopal,TRUE);
          EndPaint(hWnd,&ps);
          return 0;


The above selects and realises a palette before using WM_PRINT to get the control to draw itself using the newly selected palette.



Rob

PS For those extra 100 pts, I'll send you a full working example - post your email here.
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6900522
PPS

An alternative to subclassing the window is you use the NM_CUSTOMDRAW (CDDS_PREPAINT) notification and select the palette here. Note this feature is only supported on ComCtl32.dll v4.7 and later... then again most people do have this now as its included with Internet Explorer.
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6900543
PPS

An alternative to subclassing the window is you use the NM_CUSTOMDRAW (CDDS_PREPAINT) notification and select the palette here. Note this feature is only supported on ComCtl32.dll v4.7 and later... then again most people do have this now as its included with Internet Explorer.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 1

Author Comment

by:RolandAZ
ID: 6902328
Thanks, Rob, for the tip!

Could you please send me your working example that used "subclassing" the toolbar and one using NM_CUSTOMDRAW in Win32 API C, or in non-MFC C++ ?

Send it to rolandaz@hotmail.com

Thanks again!

I'm increasing the points by 100...
another 100, when I have incorporated your solution and satisfied my program's need. I hope it will...
0
 
LVL 5

Accepted Solution

by:
robpitt earned 1200 total points
ID: 6904745
Can't send it, your mailbox is full.

Get it from : http://63.144.255.25/downloads/misc/TB256.zip
0
 
LVL 1

Author Comment

by:RolandAZ
ID: 6904845

Great programming!
Thanks, Rob!


0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

636 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