1

I have a windows form application, and I have extended the window's frame into the client area using DwmExtendFrameIntoClientArea to get the glass effect.

Now I'm trying to show a transparent PNG image in a picture box, however the background shows up as white instead of the glass effect. How can i make the image show as transparent so that i only see the rounded gray rectangle and not the white background.

My screenshot is below. Thanks.

alt text

alt text

ace
  • 2,141
  • 7
  • 29
  • 39

2 Answers2

4

Ok, this is a kind of easy to fix problem with winforms.....what you have to do, like blam said is set the transparency key to something like: R:1, G:2, B:3...this makes everything inside your form drawn in that color transparent...all you need to do then is set the background color of your imagebox to that color...and it should draw the image's background transparently (as long as your image has transparency)

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
  • I made my form transparency key to Black, which is what i'm using to get the glass effect. Then i also set the picturebox background color to black. But it didn't work. I'm 99.9% sure my PNG is transparent. On the desktop it correctly shows as transparent. – ace Aug 21 '10 at 22:53
  • I added my picturebox image to the question, it is transparent. – ace Aug 21 '10 at 22:54
  • that was the problem, your picture wasn't transparent...here's the link to the transparent picture, download it and try using that. http://img831.imageshack.us/img831/8227/xkeyh.png – Richard J. Ross III Aug 21 '10 at 23:15
  • oh cool that worked...what setting do you use to set the transparency of the image? I used fireworks, and while exporting the image chose transparency...wierd... thanks man. – ace Aug 21 '10 at 23:21
  • your welcome! i use a free program called paint.Net...you can get it at www.getpaint.net its like photoshop, but its free i just copied your image and i used my magic wand to select the white border and press delete and viola! save and transparent! – Richard J. Ross III Aug 21 '10 at 23:25
0

Make it whatever the colour key for the glass is: Black iirc.

Blam
  • 2,888
  • 3
  • 25
  • 39
  • make what black? set the Form transpareny key to black? I tried that it does not work. – ace Aug 21 '10 at 22:51
  • Also when i set the form transparency key, the form behaves weird...when i try to maximize or close it, it looses focus and just stays there, the buttons don't work. I then have to right click on the taskbar and close it from there – ace Aug 21 '10 at 22:56