Winforms透明性问题(我为此而疯狂) [英] Winforms Transparency Issue (i going crazy with it)

查看:105
本文介绍了Winforms透明性问题(我为此而疯狂)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在下面显示一张图片,但在此之前...

i will show you an image below but before that...

如果您已看到Yahoo小部件或具有卡通/主题的Windows Media Player皮肤.

if you have seen yahoo widgets or cartoony/themed windows media player skins..

我正在减少标题栏,减少背景,减少应用程序...看起来像这样

i am building a titlebar less... background less... application... its looks like this


(来源: deviantart.net )


(source: deviantart.net)

您看到的较暗的背景实际上是我的墙纸,因为这是屏幕截图...

the darker background you see is actually my wallpaper cuz this is a screen shot...

要达到此目的..身体的形状和线条,我使用Trasparent PNG ..然后我使用Win Form的透明键使其透明..并将图像加载到图片框中...

to attain this.. the shape of body and the lines, i use Trasparent PNG.. then i use the transparency key of the Win Form to make it transparent.. and the image is loaded in a picture box...

我的问题是您在整个身体轮廓上看到的白点...这是因为该PNG中的像素不是完全不透明或不透明,即不透明...因此透明键无法使背景变为表格在这些像素处是透明的...您会看到这些白点...

my problem is the white dots you see all over the body outline... this is because the pixels of that PNG in that are not completely opaque or transparent i.e translucent... so the transparency key fails to make the background of the form transparent at those pixels... and you see these white dots...

好 还有什么其他方法可以使表单透明,因为...

well is there any other way make the form transparent because...

  • 透明度键将始终具有这样的行为,因为无论您做什么,曲线中的图像中总会存在这些半透明像素...

推荐答案

约翰内斯提到了当前方法的主要问题.

Johannes has mentioned the main issues with your current approach.

可以在Windows窗体中进行窗体alpha混合,但是您将需要使用Windows API调用(以及其他):

It is possible to do form alpha blending in Windows Forms but you will need to use the Windows API call (among others): UpdateLayeredWindow.

Visual C#kicks包含有关如何执行此操作的有用的教程和源代码创建专业外观的启动画面.

Visual C# kicks has a helpful tutorial and source code on how to do this to create a professional looking splash screen.

唯一的缺点是,如果您的表单包含子控件(例如按钮,文本框),则不会使用UpdateLayeredWindow绘制它们.但是,您仍然可以通过手动将按钮等绘制为表单背景的一部分来模拟按钮等.

The only drawback is that if your form contains child controls such as buttons, textboxes, they will not be drawn using UpdateLayeredWindow. However you could still simulate buttons etc by manually drawing them as part of the form background.

这篇关于Winforms透明性问题(我为此而疯狂)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆