点击进入透明度对于Visual C#窗口形式? [英] Click through transparency for Visual C# Window Forms?

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

问题描述

我做了一个面板,将它填满整个屏幕,现在我可以看到其下的窗户,但我希望它是通过点击,这意味着他们可以点击一个文件或看到另一个对象的工具提示通过透明度。


  

    

RE:这可能是太明显了,但是你试过送面板通过右击后,选择发送到备份


  

我的意思是像在桌面或Firefox,我的项目中不是。


解决方案

创建一个顶级形式,透明是很容易的。只是使它填满屏幕,或所需的面积,并且将其定义为具有相同的值的一个TransparenyKey颜色和背景色。

获取它忽略鼠标是很简单的,你只需要覆盖的WndProc,并告诉WM_HITTEST所有的鼠标位置是被视为透明。从而使鼠标与任何恰好是窗口下方交互。事情是这样的......

 保护覆盖无效的WndProc(参考消息M)
    {
        如果(m.Msg ==(INT)WM_NCHITTEST)
            m.Result =(IntPtr的)HTTRANSPARENT;
        其他
            base.WndProc(REF米);
    }

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天全站免登陆