一个窗体特效,帮你了解几个windows api函数.效果:windows桌面上增加一个简单的遮罩层,其中WS_EX_TRANSPARENT 比较重要,它实现了鼠标穿透的功能。

  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Runtime.InteropServices;
  5. namespace WindowsApplication40
  6. {
  7. public partial class Form1 : Form
  8. {
  9. public Form1()
  10. {
  11. InitializeComponent();
  12. }
  13. [DllImport("user32.dll", EntryPoint = "GetWindowLong")]
  14. public static extern long GetWindowLong(IntPtr hwnd, int nIndex);
  15. [DllImport("user32.dll", EntryPoint = "SetWindowLong")]
  16. public static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong);
  17. [DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")]
  18. private static extern int SetLayeredWindowAttributes(IntPtr Handle, int crKey, byte bAlpha, int dwFlags);
  19. const int GWL_EXSTYLE = -20;
  20. const int WS_EX_TRANSPARENT = 0x20;
  21. const int WS_EX_LAYERED = 0x80000;
  22. const int LWA_ALPHA = 2;
  23. private void Form1_Load(object sender, EventArgs e)
  24. {
  25. this.BackColor = Color.Silver;
  26. this.TopMost = true;
  27. this.FormBorderStyle = FormBorderStyle.None;
  28. this.WindowState = FormWindowState.Maximized;
  29. SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) | WS_EX_TRANSPARENT | WS_EX_LAYERED);
  30. SetLayeredWindowAttributes(Handle, 0, 128, LWA_ALPHA );
  31. }
  32. }
  33. }

WinForm特效:桌面上的遮罩层的更多相关文章

  1. C#使用Windows API实现桌面上的遮罩层(鼠标穿透)

    C#使用Windows API实现桌面上的遮罩层(鼠标穿透) C#实现实现桌面上的遮罩层(鼠标穿透)主要通过一下几个API函数来实现:GetWindowLong,SetWindowLong,SetLa ...

  2. Winform应用程序实现通用遮罩层

    在WEB上,我们在需要进行大数据或复杂逻辑处理时,由于耗时较长,一般我们会在处理过程中的页面上显示一个半透明的遮罩层,上面放个图标或提示:正在处理中...等字样,这样用户体验就比较好了,然而如果在Wi ...

  3. Winform应用程序实现通用遮罩层二

    之前先后发表过:<Winform应用程序实现通用遮罩层>.<Winform应用程序实现通用消息窗口>,这两款遮罩层其实都是基于弹出窗口的,今天为大家分享一个比较简单但界面相对友 ...

  4. 有时在UIWindow上添加遮罩层不成功的原因

    程序启动后,初始化window,初始化controller,加载试图,这三个方法的顺序是嵌套的 类似于: - (id) initWindow {[self initController];} 而我在i ...

  5. [C#] (原创)一步一步教你自定义控件——06,MaskLayer(遮罩层)

    一.前言 技术没有先进与落后,只有合适与不合适. 本篇的自定义控件是:遮罩层(MaskLayer). 遮罩层对软件的美观与易用性上的提高是很大的,在日常使用过程中也会经常看到各种遮罩层,虽然WinFo ...

  6. 【锋利的JQuery-学习笔记】遮罩层

    效果图:  鼠标移动到上面后---> html: <div id="jnBrandList"> <ul> <li> <a href= ...

  7. Adobe Edge Animate –地球自转动画的实现,类似flash遮罩层的效果

    Adobe Edge Animate –地球自转动画的实现,类似flash遮罩层的效果 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. 目前Edge的功能尚 ...

  8. jquery特效(7)—弹出遮罩层且内容居中

    上周写了几个小特效,其中有个点击按钮弹出遮罩层的特效,下面来看最终实现的效果: 由于是测试的程序,所以我未加关闭的按钮. 一.主体程序 <!DOCTYPE html> <html&g ...

  9. jQuery css3鼠标悬停图片显示遮罩层动画特效

    jQuery css3鼠标悬停图片显示遮罩层动画特效 效果体验:http://hovertree.com/texiao/jquery/39/ 效果图: 源码下载:http://hovertree.co ...

随机推荐

  1. Embedded之Introduction

    1 Embedded system An embedded system is a combination of computer hardware and software, and perhaps ...

  2. proguard 混淆android代码

    官网 http://proguard.sourceforge.net/#manual/examples.html android 2.3后,新建的project默认就有一个project.proper ...

  3. Module compiled with Swift 3.0 cannot be imported in Swift 3.0.1

    Cartfile:github "SwiftyJSON/SwiftyJSON"got error:Module compiled with Swift 3.0 cannot be ...

  4. linux下使用libiconv库转码

    iconv命令实现linux下字符集编码的转换 windows下的文件复制到linux下时常会乱码,因为windows下文件编码为GBK,linux下默认文件编码为UTF-8,故需要libiconv库 ...

  5. 《Java数据结构与算法》笔记-CH4-5不带计数字段的循环队列

    第四章涉及三种数据存储类型:栈,队列,优先级队列 1.概括:他们比数组和其他数据存储结构更为抽象,主要通过接口对栈,队列和优先级队列进行定义.这些 接口表明通过他们可以完成的操作,而他们的主要实现机制 ...

  6. C#获取文件的绝对路径

    要在c#中获取路径有好多方法,一般常用的有以下五种: //获取应用程序的当前工作目录. String path1 = System.IO.Directory.GetCurrentDirectory() ...

  7. html5 canvas 旋转扩大

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Mellanox vma

    1,Mellanox offical vma Installation guide personal reading summarize VMA是一个消息加速器messaging accelerato ...

  9. Linux下Python获取IP地址

    <lnmp一键安装包>中需要获取ip地址,有2种情况:如果服务器只有私网地址没有公网地址,这个时候获取的IP(即私网地址)不能用来判断服务器的位置,于是取其网关地址用来判断服务器在国内还是 ...

  10. Spark RDD概念学习系列之RDD的依赖关系(宽依赖和窄依赖)(三)

    RDD的依赖关系?   RDD和它依赖的parent RDD(s)的关系有两种不同的类型,即窄依赖(narrow dependency)和宽依赖(wide dependency). 1)窄依赖指的是每 ...