C#窗体鼠标穿透问题
c#吧
全部回复
仅看楼主
level 1
65169947 楼主
我做了个窗体然后做了鼠标穿透,但是穿透后,怎么连上面的控件也穿透了呢?怎么能只穿透窗体,而让窗体里的控件出来能够使用呢?高手速指点,郁闷好几天了,下面是代码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) { } }}
2007年06月20日 13点06分 1
level 1
我要找的正是这种效果!呵呵!
2009年03月11日 08点03分 2
level 1
请问楼主解决这个问题了吗,同求原因
2021年02月07日 12点02分 3
1