65169947 65169947
关注数: 3 粉丝数: 8 发帖数: 313 关注贴吧数: 0
C#窗体鼠标穿透问题 我做了个窗体然后做了鼠标穿透,但是穿透后,怎么连上面的控件也穿透了呢?怎么能只穿透窗体,而让窗体里的控件出来能够使用呢?高手速指点,郁闷好几天了,下面是代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using System.Drawing.Imaging;namespace WindowsApplication3{ public partial class Form1 : Form { 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 ); public Form1() { InitializeComponent(); this.CanPenetrate(); } private void Form1_Load(object sender, EventArgs e) { button1.Focus(); } private void button1_Click(object sender, EventArgs e) { this.Close(); } public void CanPenetrate() { 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); } private void pictureBox1_Click(object sender, EventArgs e) { } }}
1 下一页