c# 隐藏窗口在ALT+TAB中
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中的更多相关文章
- 怎样让窗口不显示在任务栏和ALT+TAB中(隐藏窗口再嵌套,几乎是万能的办法)
之前想弄个像QQ旋风那样的悬浮窗口,就研究了下怎么让窗口不显示在任务栏中,方法其实很简单就是将窗口的扩张属性设置成WS_EX_TOOLWINDOW,MSDN中对该属性有详细介绍,代码如下: ::Set ...
- WPF 窗体在Alt+Tab中隐藏
问题: 近段时间由于项目上的需求,需要在WPF中使用COM组件,并且由于软件界面设计等等原因,需要将部分控件显示在COM组件之上,由于WindowsFormsHost的一些原因,导致继承在WPF中的W ...
- 窗体是不出现在Alt+Tab中(窗体不出现在任务管理器中的应用程序列中)
窗体是不出现在Alt+Tab中和不出现在任务管理器中的应用程序中 重写 CreateParams即可: public class MyForm : Form{ protected override C ...
- c# 不让窗体显示在alt tab中
protected override CreateParams CreateParams { get { const int WS_EX_APPWINDOW = 0x40000; const int ...
- [转]让窗体不显示在Alt+Tab中
public class MyForm : Form { protected override CreateParams CreateParams { get { const int WS_EX_AP ...
- 在Form Load中设置showInTaskBar =false 或 隐藏窗口 this.Hide()时会导致注册的全局快捷键无效
在Form Load中设置showInTaskBar =false 或 隐藏窗口 this.Hide() 会导致注册的全局快捷键无效. 反正是其中一个,有点记不清了. 在Form Shown中s ...
- ubuntu 12.04 alt+tab无法切换窗口的问题(转载)
转自:http://www.2cto.com/os/201209/153282.html ubuntu 12.04 alt+tab无法切换窗口的问题 安装cpmpiz配置管理程序. sudo ...
- (转)js控制窗口失去焦点(包括屏蔽Alt+Tab键切换页面)
本章内容转自:http://www.cnblogs.com/BoKeYuanVinson/articles/3360954.html 转载自网络贴吧: 页面脚本是无法截获alt键的,不过可以变通一下, ...
- 在非UI线程中更改UI(Delphi使用隐藏窗口来处理,QT使用信号槽)
在Delphi里我记得是使用TThread.Synchronize(TThreadMethod),原理是利用了一个隐藏窗口来处理. 在QT Debug模式一下,碰到了同样的问题,显示错误: canno ...
随机推荐
- Spring Cloud Zuul源码
一.Zuul源码分析(初始化流程.请求处理流程)
- [洛谷P3966][TJOI2013]单词
题目大意:有$n$个字符串,求每个字符串在所有字符串中出现的次数 题解:$AC$自动机,每个节点被经过时$sz$加一,每一个字符串出现次数为其$fail$树子树$sz$和 卡点:$AC$自动机根节点为 ...
- Java线程synchronized(一)
线程安全概念:当多个线程访问某一个类(对象或方法)时,这个对象始终都能表现出正确的行为,那么这个类(对象或方法)就是线程安全的. synchronized:可以在任意对象及方法上加锁,而加锁的这段代码 ...
- MES系统之设备管理的基础功能
设备是制造企业进行生产的主要物质技术基础,制造企业的生产率.产品质量.生产成本都与设备直接相关.因此,正确使用.定时保养.及时检修维护设备,并对设备的运行性能进行分析,使设备处于良好的状态,才能保证企 ...
- java之servlet之文件下载
1.在页面中,可以直接通过超链接来下载: a) 如果浏览器能够打开该文件,那么直接在浏览器中显示---不是想要的效果 b) 任何人都能下载,不能进行权限控制 2.通过servlet来进行下载,在ser ...
- GitHub预览网页[2019最新]
GitHub预览网页 1. 创建仓库 2. 设置页面预览 3. 上传html 4. 访问网页 1. 创建仓库 登陆GitHub创建仓库 datamoko 添加基本信息: 仓库名.仓库描述,然后点击创建 ...
- java第三次面试总结
这次面试是二面,由于自己的经验不足,面试的结果不是很令人满意,所以与这家公司失之交臂,在这里记录一下经历,吸取教训. 之前的一面是笔试+面试,面试是主管,今天的面试是总监.在前台招待我的时候,还跟我说 ...
- 5.href和src区别? title和alt【CSS】
1.href (Hypertext Reference)指定网络资源的位置(超文本引用),从而在当前元素或者当前文档和由当前属性定义的需要的锚点或资源之间定义一个链接或者关系,在 link和a 等元素 ...
- SQL*Plus 格式化查询结果
为了在 SQL*Plus 环境中生成符合用户需要规范的报表,SQL*Plus 工具提供了多个用于格式化查询结果的命令,使用这些命令可以实现设置列的标题.定义输出值的显示格式和显示宽度.为报表增加头标题 ...
- Gradle3.0新指令api、provided、implementation等对比
Android Studio3.0正式版已经出来了,相比2.x的版本,Gradle版本也升级为了3.x,编译速度提高了不少. 在gadle3.0之后,默认的依赖由之前的compile更改为implem ...