表格允许点击通过在C# [英] Form allow click-through in C#

查看:126
本文介绍了表格允许点击通过在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:

  • -20GWL_EXSTYLE

    Retrieves the extended window styles.

  • 0x80000WS_EX_LAYERED

    Creates a layered window.

  • 0x20WS_EX_TRANSPARENT

    Specifies 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屋!

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