zoukankan      html  css  js  c++  java
  • C#-窗体鼠标穿透

     #region 窗体鼠标穿透
            private const uint WS_EX_LAYERED = 0x80000;
            private const int WS_EX_TRANSPARENT = 0x20;
            private const int GWL_STYLE = (-16);
            private const int GWL_EXSTYLE = (-20);
            private const int LWA_ALPHA = 0;
    
            [DllImport("user32", EntryPoint = "SetWindowLong")]
            private static extern uint SetWindowLong(
            IntPtr hwnd,
            int nIndex,
            uint dwNewLong
            );
    
            [DllImport("user32", EntryPoint = "GetWindowLong")]
            private static extern uint GetWindowLong(
            IntPtr hwnd,
            int nIndex
            );
    
            [DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")]
            private static extern int SetLayeredWindowAttributes(
            IntPtr hwnd,
            int crKey,
            int bAlpha,
            int dwFlags
            );
    
    
            /// <summary>
            /// 声明委托类
            /// </summary>
            /// <param name="MsgStr"></param>
            public delegate void FormCt();
            /// <summary>
            /// 定义委托
            /// </summary>
            public static FormCt Ct;
            /// <summary> 
            /// 设置窗体具有鼠标穿透效果 
            /// </summary> 
            private void SetPenetrate()
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(Ct);
                }
                else
                {
                    this.TopMost = true;
                    GetWindowLong(this.Handle, GWL_EXSTYLE);
                    SetWindowLong(this.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
                    SetLayeredWindowAttributes(this.Handle, 0, 100, LWA_ALPHA);
                }
            }
            #endregion

  • 相关阅读:
    区别TPS QPS HPS RPS PV UV
    C/C++常用库及工具
    CentOS常用命令备忘
    PHP的学习--Traits新特性
    CentOS7创建本地YUM源的三种方法
    CentOS下iptables详解
    Linux备份压缩命令
    Nginx HTTPS功能部署实践
    Fuel 30 分钟快速安装OpenStack
    hadoop学习通过虚拟机安装hadoop完全分布式集群
  • 原文地址:https://www.cnblogs.com/csnd/p/12062187.html
Copyright © 2011-2022 走看看