带有可见可点击控件的透明表单 [英] Transparent Form with Visible Clickable Controls in it

查看:31
本文介绍了带有可见可点击控件的透明表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 win8 和 winforms 中制作一个鼠标透明表单,其中包含可点击的控件.

I'm trying to make a mouse transparent form in win8 and winforms, that contains controls that are clickable.

我可以使用此代码使表单鼠标透明

I'm able to make the form mouse transparent, using this code

int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);

(在 win8 上 WndProc 方法不起作用)

(on win8 the WndProc approach does not work)

但是当我让表单鼠标透明时,这个表单中包含的控件也是鼠标透明的

But when I make the form mouse transparent, the controls that are contained in this form are also mouse transparent

我能做什么?

推荐答案

您可以创建一个 Form 并将 BackColorTransparencyKey 属性设置为 Color.Magenta.

You can create a Form and set both BackColor and TransparencyKey properties to Color.Magenta.

截图:

点击通过窗口并到达它后面的东西,但是如果你点击按钮1,按钮将被点击.

Click pass through window and reaches to what behind it, but of you click on button 1, button will be clicked.

注意:该技巧适用于某些颜色,例如,如果您使用 Color.Red 它将是透明的但处理点击,但使用 Magenta 表单也将是鼠标透明的.

Note: The trick works for some colors, for example if you use Color.Red it will be transparent but handles clicks, but using Magenta the form will be mouse transparent too.

这篇关于带有可见可点击控件的透明表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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