How to hide winform or WPF application from “alt+tab” and from task manager's application tab

浪子不回头ぞ 提交于 2019-12-12 01:45:18

问题


I saw many questions and answers related to this topic But I didn't find any better solution. Few solution are lengthy and few doesn't work. Now I want to share a nice and easy solution for this


回答1:


How to make application invisible in WPF. just add this XAML code

<Window x:Class="temp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="350" Width="525" ResizeMode="NoResize" WindowState="Minimized" IsTabStop="False" Visibility="Hidden" WindowStyle="None" ShowInTaskbar="False">
<Grid>

</Grid>
</Window>

Height and width dosn't matter only Visibility, WindowStyle and ShowInTaskbar will hide the application from Alt +Tab and from task manager's application tab

Now for Winform: Use Form load event and put this code

private void Form1_Load(object sender, EventArgs e)
{
    this.Opacity = 0; //Declear Opacity = 0 on top
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; //This is most Important part don't use FormBorderStyle.None or something else
    this.WindowState = FormWindowState.Minimized;
    this.ShowInTaskbar = false;
}

This will Hide Winform Application form Alt+tab as well as from task manager's application tab



来源:https://stackoverflow.com/questions/23672595/how-to-hide-winform-or-wpf-application-from-alttab-and-from-task-managers-ap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!