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. 【C++札记】多态

    C++中多态是面向对象设计思想的重要特性,同名具有不同功能函数,该函数调用过程执行不同的功能.多态的原理是通过一张虚函数表(Virtual Table)实现的.动多态会牺牲一些空间和效率来最终实现动态 ...

  2. OpenJDK自动安装脚本 InstallOpenJDK.vbs

    Oracle JDK 要收费了,Open JDK没有安装包,只有Zip,写了个安装脚本 InstallOpenJDK.vbs Rem ********************************* ...

  3. appium1.6在mac上环境搭建启动ios模拟器上Safari浏览器 转自:上海-悠悠

    前言 在mac上搭建appium踩了不少坑,先是版本低了,启动后无限重启模拟器.后来全部升级最新版本,就稳稳的了. 环境准备: 1.OS版本号10.12 2.xcode版本号8.3.2 3.appiu ...

  4. 【SQL Server数据迁移】32位的机器:SQL Server中查询ORACLE的数据

    从SQL Server中查询ORACLE中的数据,可以在SQL Server中创建到ORACLE的链接服务器来实现的,但是根据32位 .64位的机器和软件,需要用不同的驱动程序来实现. 在32位的机器 ...

  5. MySQL分库备份

    1.需求概述 每天00:00备份MySQL数据库数据: 每一个库生成一个文件,使用gzip压缩,文件名:backup_库名_yyyymmdd.sql.gz,注意yyyymmdd需要是前一天: 备份文件 ...

  6. Redis相关概念

    redis和memcache的比较 1 .Redis不仅仅支持简单的k/v类型的数据,同时还提供list,set,hash等数据结构的存储: 2 .Redis当物理内存用完时,可以将一些很久没用到的v ...

  7. 【转载】使用Winrar对压缩文件进行加密,并且给定解压密码

    有时候我们从网上下载的压缩包文件,如.rar文件.zip文件等,解压的时候需要输入解压密码才可顺利解压,否则解压失败.其实像这种情况,是压缩包制作者在压缩文件的时候对压缩文件进行了加密,输入了压缩包解 ...

  8. HTML学习摘要3

    DAY 3 浏览器会自动地在标题的前后添加空行 默认情况下,HTML 会自动地在块级元素前后添加一个额外的空行,比如段落.标题元素前后. <hr /> 标签在 HTML 页面中创建水平线. ...

  9. Winmanager,NERDTree和MiniBufExplorer

    NERDTree树形浏览文件 MiniBufExplorer多文件同时编辑 Winmanager将NERDTree和MiniBufExplorer界面整合 下载 http://www.vim.org/ ...

  10. 部署---Apache服务器安装SSL证书

    在云服务器的证书控制台下载Apache版本证书,下载到本地的是一个压缩文件. 解压后里面包含: _public.crt文件是证书文件, _chain.crt是证书链(中间证书)文件, .key文件是证 ...