C# 是否允许在C中单击透明Winform?

C# 是否允许在C中单击透明Winform?,c#,winforms,C#,Winforms,我已经在c中创建了一个winform应用程序并使其透明,但是我需要允许客户端在winform区域后面单击鼠标右键,或者如果后面有一个文件,则可以运行它吗 InitializeComponent(); SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.BackColor = Color.Transparent; this.TransparencyKey

我已经在c中创建了一个winform应用程序并使其透明,但是我需要允许客户端在winform区域后面单击鼠标右键,或者如果后面有一个文件,则可以运行它吗

        InitializeComponent();

        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = Color.Transparent;
        this.TransparencyKey = Color.Blue;
        this.FormBorderStyle = FormBorderStyle.None;

        Rectangle workingArea = Screen.GetWorkingArea(this);
        this.Location = new Point(workingArea.Right - Size.Width,
                                  workingArea.Bottom - Size.Height);

    private void FormNotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }
    private void NotifyMenuMin_Click(object sender, EventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }
    private void NotifyMenuMax_Click(object sender, EventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }

尝试对透明键和背景色使用相同的颜色,如下所示

    public TestForm()
    {
        InitializeComponent();

        this.BackColor = Color.Lime; 
        this.TransparencyKey = Color.Lime;
        this.FormBorderStyle = FormBorderStyle.None;
    }

我发现此代码有效,但使表单的所有内容都透明,而且可单击按钮不起作用: 我把钥匙颜色改成了蓝色,所以在我的表格中使用了石灰色

        InitializeComponent();
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = Color.Blue;
        this.TransparencyKey = Color.Blue;
        this.TopMost = true;
        this.FormBorderStyle = FormBorderStyle.None;

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            // Set the form click-through
            cp.ExStyle |= 0x80000 /* WS_EX_LAYERED */ | 0x20 /* WS_EX_TRANSPARENT */;
            return cp;
        }
    }

“文件隐藏”是什么意思?当我在桌面右下角运行winform应用程序时,只会出现图标,窗体区域是透明的,但如果我在窗体后面有任何文件,则无法单击/运行!”!透明键的具体选择在最新版本的Windows上很重要。与DWM aka Aero中的一个bug相关,它对您选择的颜色很敏感。这个bug的副作用是UI对眼睛是透明的,但对鼠标是透明的。颜色。蓝色恰好是一个不好的选择,颜色。红色是另一个不能正常工作的颜色。不管怎样,它们通常都是不好的选择,因为UI的其他部分可能会使用这种颜色,并在无意中变得透明。好的选择是Color.Fuchsia和Color.Lime,并遵循这些链接,以获得一个想法,如果客户有一个文件在后面,透明度是可以的!绿色区域是的,我能理解,你能试着用这个吗;而不是这个。BackColor=Color.Transparent;通过使用与背景和透明度相同的颜色,按键将允许您单击透明区域InitializeComponent;SetStyleControlStyles.SupportsTransparentBackColor,true;this.BackColor=Color.Blue;this.TransparencyKey=Color.Blue;this.TopMost=true;this.FormBorderStyle=FormBorderStyle.None;结果是一样的:如果它不起作用,就不要把它作为答案发布。汉斯·帕桑(Hans Passant)在一篇问题评论中解释说,关于透明窗体或不规则窗体形状,已经有很多重复的问题了。他解释说,使用蓝色和红色作为透明键颜色并不好,而且很可能会用在窗体的其他部分