C#使用Windows API实现桌面上的遮罩层(鼠标穿透)
C#使用Windows API实现桌面上的遮罩层(鼠标穿透)
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication40
{
public partia lclass Form1:Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll",EntryPoint="GetWindowLong")]
public static extern long GetWindowLong(IntPtr hwnd,int nIndex);
[DllImport("user32.dll",EntryPoint="SetWindowLong")]
public static extern long SetWindowLong(IntPtr hwnd,int nIndex,long dwNewLong);
[DllImport("user32",EntryPoint="SetLayeredWindowAttributes")]
public static extern int SetLayeredWindowAttributes(IntPtr Handle,int crKey,byte bAlpha,int dwFlags);
const int GWL_EXSTYLE=-20;
const int WS_EX_TRANSPARENT=0x20;
const int WS_EX_LAYERED=0x80000;
const int LWA_ALPHA=2;
private void Form1_Load(objec tsender,EventArgs e)
{
this.BackColor=Color.Silver;
this.TopMost=true;
this.FormBorderStyle=FormBorderStyle.None;
this.WindowState=FormWindowState.Maximized;
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE)|WS_EX_TRANSPARENT|WS_EX_LAYERED);
SetLayeredWindowAttributes(Handle,0,128,LWA_ALPHA);
}
}
}
以上就是介绍C#使用Windows API实现桌面上的遮罩层(鼠标穿透),希望对你有所帮助。
C#使用Windows API实现桌面上的遮罩层(鼠标穿透)的更多相关文章
- WinForm特效:桌面上的遮罩层
一个窗体特效,帮你了解几个windows api函数.效果:windows桌面上增加一个简单的遮罩层,其中WS_EX_TRANSPARENT 比较重要,它实现了鼠标穿透的功能. using Syste ...
- VC Windows API获得桌面所有窗口句柄的方法
VC Windows API应用之GetDesktopWindow ——获得桌面所有窗口句柄的方法 Windows API Windows 这个多作业系统除了协调应用程序的执行.分配内存.管理资源…之 ...
- [WinAPI] API 1 [桌面上画一个简单彩色图形]
#include<Windows.h> void GdiOut(HDC hdc); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hP ...
- Windows api实现桌面任务栏隐藏\显示
//隐藏任务栏 HWND hWnd = ::FindWindow(TEXT("Shell_traywnd"),TEXT("")); ::SetWindowPos ...
- 有时在UIWindow上添加遮罩层不成功的原因
程序启动后,初始化window,初始化controller,加载试图,这三个方法的顺序是嵌套的 类似于: - (id) initWindow {[self initController];} 而我在i ...
- c# Windows Service 桌面上显示UI
介绍 本文的目的是说明如何从Windows Vista中的服务正确启动交互式进程,以及演示如何以完全管理员权限启动该进程.交互式过程是能够在桌面上显示UI的过程. 本文介绍如何创建一个名为Loader ...
- 在Windows Server 2012中如何快速开关桌面上经典的“计算机、我的文档”等通用图标
我们都知道,在Windows Server 2012系列的服务器版本中都已经引入了Modern的现代界面作为默认的用户交互界面,同时满足视觉一致化,新版的服务器管理程序也做成了扁平化.因此传统的计算机 ...
- Windows Server 2012 R2在桌面上顯示我的電腦等圖示
Windows Server 2012 R2在桌面上顯示我的電腦等圖示 從Windows2012開始,微軟取消了服務器桌面個性化選項,如何重新調出配置界面,可以使用微軟命令調出.方法如下: 同時按 ...
- 如何在windows server 2008的桌面上显示 我的电脑
装完windows server2008 r2 x64后发现桌面只有一个回收站图标,这一点和xp 20003都差不多,但是xp 2003很容易就把桌面上的 我的电脑 我的文档 网上邻居找到,但是win ...
随机推荐
- [XJOI NOI2015模拟题13] A 神奇的矩阵 【分块】
题目链接:XJOI NOI2015-13 A 题目分析 首先,题目定义的这种矩阵有一个神奇的性质,第 4 行与第 2 行相同,于是第 5 行也就与第 3 行相同,后面的也是一样. 因此矩阵可以看做只有 ...
- PHP ini_set() 函数
PHP ini_set用来设置php.ini的值,在函数执行的时候生效,对于虚拟空间来说,很方便,下面为大家介绍下此方法的使用 PHP ini_set用来设置php.ini的值,在函数执行的时候生效, ...
- Python 标准库 urllib2 的使用细节
刚好用到,这篇文章写得不错,转过来收藏. 转载自 道可道 | Python 标准库 urllib2 的使用细节 Python 标准库中有很多实用的工具类,但是在具体使用时,标准库文档上对使用细节 ...
- Newtonsoft.Json.JsonWriter
[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4754769.html] JsonWriter使用: 前台 $.post("Ajax ...
- Show username instead of "System Account" in SharePoint 2010
Problems: When I load my local SharePoint site, the account always show as "System Account" ...
- is present but cannot be translated into a null value due to being declared as a primitive type
解决办法:把基本类型改为对象,譬如此处将pageId的类型由int 改为Integer 2016-10-19 19:36:11.275 DEBUG [http-nio-9999-exec-2][org ...
- 手势识别官方教程(8)拦截触摸事件,得到触摸的属性如速度,距离等,控制view展开
onInterceptTouchEvent可在onTouchEvent()前拦截触摸事件, ViewConfiguration得到触摸的属性如速度,距离等, TouchDelegate控制view展开 ...
- BZOJ_1016_[JSOI2008]_最小生成树计数_(dfs+乘法原理)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1016 给出一张图,其中具有相同权值的边的数目不超过10,求最小生成树的个数. 分析 生成树的计 ...
- 五个你可能闻所未闻的出色的Ubuntu替代发行版
你在使用Ubuntu,可是希望桌面体验……来得更眩目一点.虽说你总是可以添加新的桌面背景,或者索性切换桌面,但是你还有这个选择:换成一种全然不同的发行版. 本文就介绍了五个极其出色的Ubuntu替 ...
- Qt: The State Machine Framework 学习
State Machine,即为状态机,是Qt中一项非常好的框架.State Machine包括State以及State间的Transition,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...