XP 中的 C# 透明度
我有一个小启动窗口:
public partial class Splash : Form
{
bool painted = false;
public Splash()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
//
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (painted)
return;
Graphics gfx = e.Graphics;
gfx.DrawImage(Properties.Resources.Splash, ClientRectangle);
painted = true;
}
}
Properties.Resources.Splash
是带有 alpha 的 PNG,在我的 Windows 7 开发计算机上显示精美。
然而,在 Windows XP 目标计算机上,不存在透明度;相反,图像的背景是黑色的。
我知道在 XP 中可以显示透明的启动窗口,因为我以前见过它。可以在.net 中实现吗?如果是这样,怎么办?
I have a little splash window:
public partial class Splash : Form
{
bool painted = false;
public Splash()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
//
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (painted)
return;
Graphics gfx = e.Graphics;
gfx.DrawImage(Properties.Resources.Splash, ClientRectangle);
painted = true;
}
}
Properties.Resources.Splash
is a PNG with alpha, and displays beautifully on my Windows 7 development computer.
On the Windows XP target computers, however, there is no transparency; instead, the background of the image is black.
I know it's possible to display a transparent splash window in XP because I have seen it before. Is it possible to do it in .net? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可以通过 WS_EX_LAYERED 完成,但需要一些努力和一些 P/Invoke:http://msdn.microsoft.com/en-us/library/ms997507.aspx" rel="nofollow">http:// /msdn.microsoft.com/en-us/library/ms997507.aspx
这里还有一篇较旧的文章,但不知道它是否仍然有效:http://www.codeproject.com/KB/cs/transparentwindowsincsharp.aspx
It can be done with WS_EX_LAYERED but requires some efforts and some P/Invoke: http://msdn.microsoft.com/en-us/library/ms997507.aspx
Also there is an older article here but don't know if it's still valid: http://www.codeproject.com/KB/cs/transparentwindowsincsharp.aspx