收藏 分销(赏)

鼠标穿透窗体.doc

上传人:仙人****88 文档编号:8667292 上传时间:2025-02-24 格式:DOC 页数:3 大小:13.05KB
下载 相关 举报
鼠标穿透窗体.doc_第1页
第1页 / 共3页
鼠标穿透窗体.doc_第2页
第2页 / 共3页
点击查看更多>>
资源描述
把窗体的FormBorderStyle设为FormBorderStyle.None using System.Runtime.InteropServices; 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 ); /// <summary> /// 使窗口有鼠标穿透功能 /// </summary> 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); } 要时窗体恢复正常,只要执行以下语句: this.FormBorderStyle = FormBorderStyle.None;
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服