WinForm特效:桌面上的遮罩层
一个窗体特效,帮你了解几个windows api函数.效果:windows桌面上增加一个简单的遮罩层,其中WS_EX_TRANSPARENT 比较重要,它实现了鼠标穿透的功能。
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace WindowsApplication40
- {
- public partial class 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")]
- private 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(object sender, 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 );
- }
- }
- }
WinForm特效:桌面上的遮罩层的更多相关文章
- C#使用Windows API实现桌面上的遮罩层(鼠标穿透)
C#使用Windows API实现桌面上的遮罩层(鼠标穿透) C#实现实现桌面上的遮罩层(鼠标穿透)主要通过一下几个API函数来实现:GetWindowLong,SetWindowLong,SetLa ...
- Winform应用程序实现通用遮罩层
在WEB上,我们在需要进行大数据或复杂逻辑处理时,由于耗时较长,一般我们会在处理过程中的页面上显示一个半透明的遮罩层,上面放个图标或提示:正在处理中...等字样,这样用户体验就比较好了,然而如果在Wi ...
- Winform应用程序实现通用遮罩层二
之前先后发表过:<Winform应用程序实现通用遮罩层>.<Winform应用程序实现通用消息窗口>,这两款遮罩层其实都是基于弹出窗口的,今天为大家分享一个比较简单但界面相对友 ...
- 有时在UIWindow上添加遮罩层不成功的原因
程序启动后,初始化window,初始化controller,加载试图,这三个方法的顺序是嵌套的 类似于: - (id) initWindow {[self initController];} 而我在i ...
- [C#] (原创)一步一步教你自定义控件——06,MaskLayer(遮罩层)
一.前言 技术没有先进与落后,只有合适与不合适. 本篇的自定义控件是:遮罩层(MaskLayer). 遮罩层对软件的美观与易用性上的提高是很大的,在日常使用过程中也会经常看到各种遮罩层,虽然WinFo ...
- 【锋利的JQuery-学习笔记】遮罩层
效果图: 鼠标移动到上面后---> html: <div id="jnBrandList"> <ul> <li> <a href= ...
- Adobe Edge Animate –地球自转动画的实现,类似flash遮罩层的效果
Adobe Edge Animate –地球自转动画的实现,类似flash遮罩层的效果 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. 目前Edge的功能尚 ...
- jquery特效(7)—弹出遮罩层且内容居中
上周写了几个小特效,其中有个点击按钮弹出遮罩层的特效,下面来看最终实现的效果: 由于是测试的程序,所以我未加关闭的按钮. 一.主体程序 <!DOCTYPE html> <html&g ...
- jQuery css3鼠标悬停图片显示遮罩层动画特效
jQuery css3鼠标悬停图片显示遮罩层动画特效 效果体验:http://hovertree.com/texiao/jquery/39/ 效果图: 源码下载:http://hovertree.co ...
随机推荐
- windows系统下Python环境的搭建及Selenium的安装
1.首先访问http://www.python.org/download/去下载最新的python版本: 2.下载安装包,一路安装完毕: 3.为计算机添加安装目录搭到环境变量,如图把python的安装 ...
- SSD Cloud Hosting–Linode-Mysql数据库的安装与配置
接着上一篇的话题:SSD Cloud Hosting - Linode的配置和部署,搭建Java环境 8.Mysql数据库的安装与配置 安装 检查yum里边有没有mysql: yum list|gre ...
- int (*p)[4] p 是二级指针 二维数组 二级指针 .xml
pre{ line-height:1; color:#2f88e4; background-color:#e9ffff; font-size:16px;}.sysFunc{color:#3d7477; ...
- First step of using junit---------Software Testing Lab 1---2016.03.18
1. Install junit a) Download “junit.jar” b) In eclipse, Windows->Preferences->Java-& ...
- C++C#时间转换
time_t是从1970年1月1日的格林尼治时间开始的,所以以下就是你要的结果System.DateTime time= new System.DateTime(1970, 1, 1).ToLocal ...
- [转] Python自动单元测试框架
一.软件测试 大型软件系统的开发是一个很复杂的过程,其中因为人的因素而所产生的错误非常多,因此软件在开发过程必须要有相应的质量保证活动,而软件测试则是保证质量的关键措施.正像软件熵(software ...
- 使用ReflectionTestUtils解决依赖注入
概述 当使用junit来测试Spring的代码时,为了减少依赖,需要给对象的依赖,设置一个mock对象,但是由于Spring可以使用@Autoware类似的注解方式,对私有的成员进行赋值,此时无法 ...
- iOS 后台退出app时不执行applicationWillTerminate的临时解决方法
- (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release s ...
- Html.DropDownListFor
@Html.DropDownListFor(x => x.WillAttend, new[] { new SelectListItem() {Text = "Yes, I'll be ...
- Java断言assert
public class Welcome{ public static void main(String[] args){ assert false; System.out.println(" ...