表格允许点击通过在C# [英] Form allow click-through in C#
问题描述
嘿,我有一个表格,我已经将其设置为半透明。我希望人们能够点击表格区域,形式不处理一下,而是不管它的下面处理click是。 ?这是可能的。
您可以用 SetWindowLong函数
做到这一点:
INT initialStyle = GetWindowLong(this.Handle,-20);
SetWindowLong函数(this.Handle,-20,initialStyle | 0x80000 | 0x20的);
有一些神奇的数字在这里:
-
-20
- GWL_EXSTYLE
检索扩展的窗口样式。
块引用> -
0x80000
- WS_EX_LAYERED
创建分层。窗口
块引用> -
0x20的
- WS_EX_TRANSPARENT
指定使用这种风格创建的窗口不应该涂,直到窗下的兄弟姐妹(即由同一线程创建的)都被涂。因为底层的兄弟窗口的位已经画了窗口看起来是透明的。
块引用>
有许多文章遍关于如何做到这一点的网站,如这个一>
Hey, so I have a form, and i've set it to semi-transparent. i'd like for people to be able to click on the forms area, and the form not handle the click, but instead whatever is underneath it handle the click. is this possible?
You can do this with SetWindowLong
:
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
There are a few magic numbers in here:
-20
– GWL_EXSTYLERetrieves the extended window styles.
0x80000
– WS_EX_LAYEREDCreates a layered window.
0x20
– WS_EX_TRANSPARENTSpecifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.
There are numerous articles all over the web on how to do this, such as this one.
这篇关于表格允许点击通过在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!