winform:

        protected override CreateParams CreateParams
{
get
{
const int WS_EX_APPWINDOW = 0x40000;
const int WS_EX_TOOLWINDOW = 0x80;
CreateParams cp = base.CreateParams;
cp.ExStyle &= (~WS_EX_APPWINDOW); // 不显示在TaskBar
cp.ExStyle |= WS_EX_TOOLWINDOW; // 不显示在Alt-Tab
return cp;
}
}

WPF:

#region Window styles
[Flags]
public enum ExtendedWindowStyles
{
// ...
WS_EX_TOOLWINDOW = 0x00000080,
// ...
} public enum GetWindowLongFields
{
// ...
GWL_EXSTYLE = (-),
// ...
} [DllImport("user32.dll")]
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex); public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
int error = ;
IntPtr result = IntPtr.Zero;
// Win32 SetWindowLong doesn't clear error on success
SetLastError(); if (IntPtr.Size == )
{
// use SetWindowLong
Int32 tempResult = IntSetWindowLong(hWnd, nIndex, IntPtrToInt32(dwNewLong));
error = Marshal.GetLastWin32Error();
result = new IntPtr(tempResult);
}
else
{
// use SetWindowLongPtr
result = IntSetWindowLongPtr(hWnd, nIndex, dwNewLong);
error = Marshal.GetLastWin32Error();
} if ((result == IntPtr.Zero) && (error != ))
{
throw new System.ComponentModel.Win32Exception(error);
} return result;
} [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)]
private static extern IntPtr IntSetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)]
private static extern Int32 IntSetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong); private static int IntPtrToInt32(IntPtr intPtr)
{
return unchecked((int)intPtr.ToInt64());
} [DllImport("kernel32.dll", EntryPoint = "SetLastError")]
public static extern void SetLastError(int dwErrorCode);
#endregion private void image_Loaded(object sender, RoutedEventArgs e)
{
WindowInteropHelper wndHelper = new WindowInteropHelper(this); int exStyle = (int)GetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE); exStyle |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW; SetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle);
}
————————————————

原文链接:https://blog.csdn.net/qq452626100/article/details/52314283

c# 隐藏窗口在ALT+TAB中的更多相关文章

  1. 怎样让窗口不显示在任务栏和ALT+TAB中(隐藏窗口再嵌套,几乎是万能的办法)

    之前想弄个像QQ旋风那样的悬浮窗口,就研究了下怎么让窗口不显示在任务栏中,方法其实很简单就是将窗口的扩张属性设置成WS_EX_TOOLWINDOW,MSDN中对该属性有详细介绍,代码如下: ::Set ...

  2. WPF 窗体在Alt+Tab中隐藏

    问题: 近段时间由于项目上的需求,需要在WPF中使用COM组件,并且由于软件界面设计等等原因,需要将部分控件显示在COM组件之上,由于WindowsFormsHost的一些原因,导致继承在WPF中的W ...

  3. 窗体是不出现在Alt+Tab中(窗体不出现在任务管理器中的应用程序列中)

    窗体是不出现在Alt+Tab中和不出现在任务管理器中的应用程序中 重写 CreateParams即可: public class MyForm : Form{ protected override C ...

  4. c# 不让窗体显示在alt tab中

    protected override CreateParams CreateParams { get { const int WS_EX_APPWINDOW = 0x40000; const int ...

  5. [转]让窗体不显示在Alt+Tab中

    public class MyForm : Form { protected override CreateParams CreateParams { get { const int WS_EX_AP ...

  6. 在Form Load中设置showInTaskBar =false 或 隐藏窗口 this.Hide()时会导致注册的全局快捷键无效

    在Form Load中设置showInTaskBar =false   或 隐藏窗口 this.Hide() 会导致注册的全局快捷键无效.  反正是其中一个,有点记不清了. 在Form Shown中s ...

  7. ubuntu 12.04 alt+tab无法切换窗口的问题(转载)

    转自:http://www.2cto.com/os/201209/153282.html ubuntu 12.04 alt+tab无法切换窗口的问题   安装cpmpiz配置管理程序.   sudo ...

  8. (转)js控制窗口失去焦点(包括屏蔽Alt+Tab键切换页面)

    本章内容转自:http://www.cnblogs.com/BoKeYuanVinson/articles/3360954.html 转载自网络贴吧: 页面脚本是无法截获alt键的,不过可以变通一下, ...

  9. 在非UI线程中更改UI(Delphi使用隐藏窗口来处理,QT使用信号槽)

    在Delphi里我记得是使用TThread.Synchronize(TThreadMethod),原理是利用了一个隐藏窗口来处理. 在QT Debug模式一下,碰到了同样的问题,显示错误: canno ...

随机推荐

  1. DS 壹之型 头指针与头结点

    之前结合网上博客整理的笔记,希望能帮你解除疑惑!    

  2. xorm -Alias,Asc,Desc方法实例

    Alias(string)给Table设定一个别名 package main import ( "fmt" _ "github.com/go-sql-driver/mys ...

  3. windows10环境下的RabbitMQ使用_笔记

    使用默认账号:guest/guest登录http://localhost:15672/#/进去,添加一个新用户(Administrator权限),并设置其Permission 新建两个控制台程序 安装 ...

  4. [jsp学习笔记]jstl标签的使用

    jstl常用在html嵌套 <body> <% session.setAttribute("q", "yushi"); request.set ...

  5. node.js开发 npm包管理工具

    npm介绍 说明:npm(node package manager)是nodejs的包管理器,用于node插件管理(包括安装.卸载.管理依赖等) 使用npm安装插件:命令提示符执行npm instal ...

  6. 和我一起,重零开始学习Ant Design Pro开发解决方案(二)部署示例项目

  7. 深入理解JVM(五) -- 垃圾回收算法

    上篇文章我们了解到哪些内存区域和哪些对象可以被回收,这篇文章我们就来了解一下具体的垃圾回收算法的思路,不讨论具体的实现. 一 最基础算法 标记-清除(Mark-Swap) 为什么说他是最基础的算法,因 ...

  8. JavaScript前端图片压缩

    实现思路 获取input的file 使用fileReader() 将图片转为base64 使用canvas读取base64 并降低分辨率 把canvas数据转成blob对象 把blob对象转file对 ...

  9. python 标准库subprocess

    作者:Vamei 出处:http://www.cnblogs.com/vamei subprocess包主要功能是执行外部的命令和程序.subprocess的功能与shell类似.subprocess ...

  10. mongdb插入 查询时间

    Robo 3T mongdb客户端 https://www.robomongo.org/ 模糊查找关键字 db.getCollection('test').find({"name" ...