• C# 设置Windows程序窗口为穿透状态


    代码:

     1         private const uint WS_EX_LAYERED = 0x80000;
     2         private const int WS_EX_TRANSPARENT = 0x20;
     3         private const int GWL_STYLE = (-16);
     4         private const int GWL_EXSTYLE = (-20);
     5         private const int LWA_ALPHA = 0;
     6 
     7         [DllImport("user32", EntryPoint = "SetWindowLong")]
     8         private static extern uint SetWindowLong(
     9         IntPtr hwnd,
    10         int nIndex,
    11         uint dwNewLong
    12         );
    13 
    14         [DllImport("user32", EntryPoint = "GetWindowLong")]
    15         private static extern uint GetWindowLong(
    16         IntPtr hwnd,
    17         int nIndex
    18         );
    19 
    20         [DllImport("user32", EntryPoint = "SetLayeredWindowAttributes")]
    21         private static extern int SetLayeredWindowAttributes(
    22         IntPtr hwnd,
    23         int crKey,
    24         int bAlpha,
    25         int dwFlags
    26         );
    27 
    28         /// <summary> 
    29         /// 设置窗体具有鼠标穿透效果 
    30         /// </summary> 
    31         public void SetPenetrate()
    32         {
    33             this.TopMost = true;
    34             GetWindowLong(this.Handle, GWL_EXSTYLE);
    35             SetWindowLong(this.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
    36             SetLayeredWindowAttributes(this.Handle, 0, 100, LWA_ALPHA);
    37         }
  • 相关阅读:
    Java实现交替字符串
    Java实现交替字符串
    Java实现格子取数问题
    Java实现格子取数问题
    Java实现格子取数问题
    Java实现格子取数问题
    Java实现格子取数问题
    主要C++流派,看看你是哪一流
    WPF与WinForm的抉择
    编译icu库(用到了cygwin)
  • 原文地址:https://www.cnblogs.com/Red-ButterFly/p/7726534.html
Copyright © 2020-2023  润新知