I wanted to have a .png image (which has transparency) appear on a tab, but the default behavior (using an imagelist and imageIndex) doesn't seem to respect the transparency within the image (it shows up as white). Is there a better/different way to draw the image on the tab so as to get the transparency effect? Thanks!
Sorry for the delay, I will get back to you before the end of the day regarding this issue. And I suppose you are working in XP?
IPIvan PellyMarch 13, 2003 12:35 PM UTC
No, 2000, but hopefully the solution would work for both...
Ramesh PraveenMarch 13, 2003 05:44 PM UTC
I am not sure if this will work in win2k. Try associating the ImageList to a ListView's item and see if it draws transparently.
We have also noticed that filling the ImageList through the designer with an icon that has transparency info, causes the resultant image to lose it's transparency info. So, if the above doesn't work, try filling it through code, like this for example:
// Create our own 24X imagelist
this.icons24X = new System.Windows.Forms.ImageList();
this.icons24X.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.icons24X.ImageSize = new System.Drawing.Size(24, 24);
// Create a holder for reading icons
// Read icon files and insert into our 24X imagelist (without losing the alpha channel)
icoHolder = new System.Drawing.Icon("transIco.ico");
We have tested that initing an ImageList like this is required for it to retain the alpha channel and draw semi-transparently in XP.
Coming to the TabControlExt, we noticed that it was not equipped to work with these icons with alpha channel. We have internally fixed this behavior and the icons will draw with the alpha channel in (only)XP. Please login a support incident so that we can inform you when a patch is available.
IPIvan PellyMarch 17, 2003 12:52 PM UTC
Is there perhaps a workaround, something like an OnDraw override, and using Graphics.DrawIcon to draw an icon on the tab? Thanks again.
Ramesh PraveenMarch 18, 2003 03:48 PM UTC
That might be an option if you can't wait for our next patch.
IPIvan PellyMarch 21, 2003 06:40 PM UTC
Any insights on how to go about this. I played around a bit, without success. Thanks.
Ramesh PraveenMarch 24, 2003 07:42 PM UTC
includes a fix for the transparency problem in the tabcontrol.
IPIvan PellyMarch 25, 2003 06:25 PM UTC
Thanks - I installed the patch, but to no avail. I tried setting the TransparentColor of the imagelist to Transparent, then White, with the same results each time. Attached are the .png images I'm using, and a picture of the tab. (I use the same images in the grid, and they draw fine). Please let me know if I can provide any more info. Thanks!
Ramesh PraveenMarch 27, 2003 05:46 PM UTC
Are you trying this in 2000? As I mentioned before, I don't think it will work in 2000. It has to be XP.
In any case, once you load these images to an ImageList, make a ListView use this same ImageList and see how it gets drawn, it's the same way our tabs will get drawn too.