C# 如何从Flip3D中删除WPF应用程序?
如何使WPF窗口永远不会出现在Flip3d(Winkey+Tab)对话框中?只需将主窗体的ShowInTaskbar设置为false:C# 如何从Flip3D中删除WPF应用程序?,c#,wpf,aero,flip3d,C#,Wpf,Aero,Flip3d,如何使WPF窗口永远不会出现在Flip3d(Winkey+Tab)对话框中?只需将主窗体的ShowInTaskbar设置为false: <Window x:Class="WpfNoFlip3D.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Window x:Class="WpfNoFlip3D.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" ShowInTaskbar="False">
<Grid>
</Grid>
</Window>
请注意,它不适用于Alt+Tab,只适用于Win+Tab(根据您的要求)
副作用是,您的应用程序也将从任务栏中消失。以下是我的操作方法:
...
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace NoFlip3D
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[Flags]
public enum DwmWindowAttribute
{
NCRenderingEnabled = 1,
NCRenderingPolicy,
TransitionsForceDisabled,
AllowNCPaint,
CaptionButtonBounds,
NonClientRtlLayout,
ForceIconicRepresentation,
Flip3DPolicy,
ExtendedFrameBounds,
HasIconicBitmap,
DisallowPeek,
ExcludedFromPeek,
Last
}
[Flags]
public enum DwmNCRenderingPolicy
{
UseWindowStyle,
Disabled,
Enabled,
Last
}
public MainWindow()
{
InitializeComponent();
}
public static void RemoveFromFlip3D(IntPtr Hwnd)
{
int renderPolicy = (int)DwmNCRenderingPolicy.Enabled;
DwmSetWindowAttribute(Hwnd, (int)DwmWindowAttribute.Flip3DPolicy, ref renderPolicy, sizeof(int));
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
IntPtr AppHandle = new WindowInteropHelper(this).Handle;
RemoveFromFlip3D(AppHandle);
}
}
}
。。。
使用System.Runtime.InteropServices;
使用System.Windows.Interop;
命名空间NoFlip3D
{
///
///MainWindow.xaml的交互逻辑
///
公共部分类主窗口:窗口
{
[DllImport(“dwmapi.dll”,PreserveSig=false)]
公共静态外部int DwmSetWindowAttribute(IntPtr hwnd、int attr、ref int attrValue、int attrSize);
[旗帜]
公共枚举DwmWindowAttribute
{
NCRenderingEnabled=1,
招标政策,
转换强制禁用,
AllowNCPaint,
标题按钮边界,
非客户端布局,
力象表征,
新政策,
扩展框架边界,
HasIconicBitmap,
不允许周,
不包括从Peek,
最后
}
[旗帜]
公共枚举DwmNCRenderingPolicy
{
使用窗口样式,
残废
启用,
最后
}
公共主窗口()
{
初始化组件();
}
从Flip3D移除公共静态无效(IntPtr Hwnd)
{
int renderPolicy=(int)DwmNCRenderingPolicy.Enabled;
DwmSetWindowAttribute(Hwnd,(int)DwmWindowAttribute.Flip3DPolicy,ref renderPolicy,sizeof(int));
}
已加载私有无效窗口(对象发送器、路由目标)
{
IntPtr AppHandle=new WindowInteropHelper(this).Handle;
从Flip3D(AppHandle)中移除;
}
}
}
它对Flip3D隐藏,而其他选项保持原样(alt选项卡和任务栏)但是,当Flip3D运行时,应用程序仍在后台显示我不相信您可以。如果进程正在运行,并且它有一个用户可以看到的窗体/窗口,人们会希望Microsoft不允许这样做,否则编写恶意软件会很容易。我相信这可能是一个重复的问题。这是假设Alt Tab和Win Tab在幕后使用相同的窗口样式。请参阅:这将从Alt+Tab对话框中删除,但对flip 3d不起作用。感谢您的回复,但我需要一个解决方案,只从Flip3d而不是任务栏中删除。