单击 Visual C# 窗口窗体的透明度? [英] Click through transparency for Visual C# Window Forms?

查看:19
本文介绍了单击 Visual C# 窗口窗体的透明度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个面板并将其设置为填满屏幕,现在我可以看到它下面的窗口,但我希望它被点击,这意味着他们可以点击一个文件或通过透明度看到另一个对象的工具提示.

<块引用><块引用>

RE:这可能太明显了,但是您是否尝试过通过右键单击并选择Send to Back"将面板发送到后面?

我的意思是像桌面或火狐一样,而不是我项目中的东西.

解决方案

创建透明的顶级表单非常容易.只需让它填满屏幕或所需区域,并将其定义为具有相同值的 TransparenyKey 颜色和 BackColor.

让它忽略鼠标很简单,您只需要覆盖 WndProc 并告诉 WM_HITTEST 所有鼠标位置都将被视为透明.从而导致鼠标与窗口下方的任何东西进行交互.像这样……

 protected override void WndProc(ref Message m){if (m.Msg == (int)WM_NCHITTEST)m.Result = (IntPtr)HTTRANSPARENT;别的base.WndProc(ref m);}

I made a panel and set it to fill the screen, now I can see the windows under it but I want it to be click through, meaning they could click a file or see a tool tip of another object through the transparency.

RE: This may be too obvious, but have you tried sending the panel to the back by right clicking and choosing "Send to Back"?

I mean like the desktop or firefox, not something within my project.

解决方案

Creating a top level form that is transparent is very easy. Just make it fill the screen, or required area, and define it to have a TransparenyKey color and BackColor of the same value.

Getting it to ignore the mouse is simple enough, you just need to override the WndProc and tell the WM_HITTEST that all mouse positions are to be treated as transparent. Thus causing the mouse to interact with whatever happens to be underneath the window. Something like this...

    protected override void WndProc(ref Message m)
    {
        if (m.Msg == (int)WM_NCHITTEST)
            m.Result = (IntPtr)HTTRANSPARENT;
        else
            base.WndProc(ref m);
    }

这篇关于单击 Visual C# 窗口窗体的透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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