从 ALT+TAB 菜单隐藏无边框窗口

2024-05-05

我正在开发一个带有无边界表单的托盘应用程序,该应用程序在后台运行。 如果用户想要执行不同的操作,他们可以通过右键单击托盘图标(NotifyIcon)来打开上下文菜单。

所以我的要求是:

1.应用程序始终以最小化模式启动,并且将显示托盘图标。
2.应用程序不应出现在任务栏中。
3.应用程序不应从 ALT+TAB 菜单中可见。

I have implemented above two requirements but while trying to hide the application from ALT+Tab menu it is working (not visible from ALT+TAB) but its creating small edged window with application title at left side corner on top of Taskbar as shown in below image: enter image description here

我想去掉那个小边窗。

这是我的代码:

    public Form1()
    {
        InitializeComponent();
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        HideThisForm();
    }

    protected override CreateParams CreateParams
    {
        get
        {
            // Turn on WS_EX_TOOLWINDOW style bit
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x80;
            return cp;
        }
    }

    private void HideThisForm()
    {

        this.ShowInTaskbar = false;
        this.WindowState = FormWindowState.Minimized;
        this.Hide();

        notifyApp.Visible = true;
        notifyApp.ShowBalloonTip(2000, "BackgroundApp", 
                    "This APP is running @ Background", ToolTipIcon.Info);
    }

P.S:我在 StackOverflow 上浏览过一些类似的帖子,但没有一个遇到类似的问题。


我在使用之前已经完成了这个this.Opacity=0;。有点 hackish,但对于 WinForms,这可能是唯一的方法。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从 ALT+TAB 菜单隐藏无边框窗口 的相关文章

随机推荐