none
如何取消鼠标穿透,最后3句是穿透代码 RRS feed

  • 问题

  •  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 = 0x2;

            [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
            );

     private void label3_Click(object sender, EventArgs e)
            {  uint intExTemp = GetWindowLong(this.Handle, GWL_EXSTYLE);
               uint oldGWLEx = SetWindowLong(this.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
            SetLayeredWindowAttributes(this.Handle, 0, 100, LWA_ALPHA);


            }

    2013年6月3日 4:33

答案

全部回复