Display only an Image with Transparency in a Windows Form?

梦想的初衷 提交于 2019-12-12 19:26:34

问题


I'm trying to get a form in my Windows Forms program to be borderless, invisible, and have a PictureBox control in it. The PictureBox image is set to a PNG with an alpha channel to give it a transparent background.

What I want is for the form to be completely invisible but I want the PNG with correct transparency to be visible still.

This is only going to be for Windows 7 with Aero theme on so any shortcuts Areo can afford me I can use.

I tried using a transparency key for the form like so:

this.TransparencyKey = Color.Turquoise;
this.BackColor = Color.Turquoise;

This ALMOST works except the parts of the PNG that aren't 100% transparent pick up the turquoise and gives the PNG an ugly turquoise halo around it.

EDIT: I found this article which sounds like it might be what I'm looking for but it doesn't go into specifics on implementation. Would this work for me? How do I do it?


回答1:


I found a solution in this source code here:

http://www.codeproject.com/Articles/29184/A-lovely-goldfish-desktop-pet-using-alpha-PNG-and



来源:https://stackoverflow.com/questions/15208767/display-only-an-image-with-transparency-in-a-windows-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!