简体   繁体   English

带有可见可点击控件的透明表单

[英]Transparent Form with Visible Clickable Controls in it

I'm trying to make a mouse transparent form in win8 and winforms, that contains controls that are clickable.我正在尝试在 win8 和 winforms 中制作一个鼠标透明表单,其中包含可点击的控件。

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);

(on win8 the WndProc approach does not work) (在 win8 上 WndProc 方法不起作用)

But when I make the form mouse transparent, the controls that are contained in this form are also mouse transparent但是当我让表单鼠标透明时,这个表单中包含的控件也是鼠标透明的

What can I do?我能做什么?

You can create a Form and set both BackColor and TransparencyKey properties to Color.Magenta .您可以创建一个 Form 并将BackColorTransparencyKey属性设置为Color.Magenta

Screenshot:截屏:

在此处输入图片说明

Click pass through window and reaches to what behind it, but of you click on button 1, button will be clicked.单击通过窗口并到达其后面的内容,但是如果您单击按钮 1,则按钮将被单击。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM