views:

147

answers:

2

I'm very new to C# and I've run into a problem and haven't been able to solve it. I have a row of buttons that have .png images assigned to them. The images are in .png format to allow transparency, and smoothing the edges in GIMP leaves some semi-transparent pixels. I've set the Image List Toolbar (imglToolbar)'s properties to recognize "Transparent" as the designated color to show up as transparent. I'm working in Visual Studio 2005.

The strange thing is that everything looks great when I'm viewing the Visual C# form preview window. The icons look exactly as they should. However, once I actually build the project, the buttons treat every semi-transparent pixel near the edge of the image as if it's black. It seems like it can't handle one that's both transparent and has color.

Image of it via the Visual C# form editor:

alt text

Image of what it looks like when built:

alt text

Any ideas as to why this is happening?

+1  A: 

I ran into this problem as well; changing the form's IsMdiContainer property to false solved it.

Laplace
Thanks, but it looks like it needs to stay an MDI container. Bummer.
Sean O'Hollaren
+1  A: 

I just found the answer, at least to my specific situation.

The form I'm dealing with is a top-level MDI container. For whatever reason, having the icons set to 32 bit color doesn't allow for these semi-transparent pixels to be properly interpreted. Setting it to 24-bit, on a whim, completely solved the problem. Not sure if this is some situation that has come up as a result of some unseen factor, but the color depth change fixed my problem.

Also for those who may come here with a similar problem, make sure the window isn't a child of an MDI container. While looking for information, I found MDI children don't support TransparencyKeys at all.

Sean O'Hollaren