从 ALT+TAB 菜单隐藏无边框窗口 [英] Hiding Borderless Window from ALT+TAB menu

查看:46
本文介绍了从 ALT+TAB 菜单隐藏无边框窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm developing a Tray application with Borderless Form which runs in the background. if user wants to perform different operations, they can open context menu by right clicking on the tray icon(NotifyIcon).

所以我的要求是:

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

1.Application always starts in minimized mode and trayicon willbe displayed.
2.Application should not be appeared from the Taskbar.
3.Application should not be visible from ALT+TAB menu.

我已经实现了以上两个要求,但是在尝试从 ALT+Tab 菜单中隐藏应用程序时,它正在工作(从 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:

我想移除那个小边窗.

这是我的代码:

    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 上看过几个类似的帖子,但没有一个遇到类似的问题.

P.S: i have gone through few similar posts in StackOverflow but none of them facing similar issue.

推荐答案

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

I've accomplished this before using this.Opacity=0;. Kind of hackish, but with WinForms, it might be the only way.

这篇关于从 ALT+TAB 菜单隐藏无边框窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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