一个窗体特效帮你了解几个windows api函数效果windows桌面上增加一个简单的遮罩层其中WS_EX_TRANSPARENT 比较重要它实现了鼠标穿透的功能 using System; using SystemDrawing; using SystemWindowsForms; using SystemRuntimeInteropServices; namespace WindowsApplication { public partial class Form : Form { public Form() { InitializeComponent(); } [DllImport(userdll EntryPoint = GetWindowLong)] public static extern long GetWindowLong(IntPtr hwnd int nIndex); [DllImport(userdll EntryPoint = SetWindowLong)] public static extern long SetWindowLong(IntPtr hwnd int nIndex long dwNewLong); [DllImport(user EntryPoint = SetLayeredWindowAttributes)] private static extern int SetLayeredWindowAttributes(IntPtr Handle int crKey byte bAlpha int dwFlags); const int GWL_EXSTYLE = ; const int WS_EX_TRANSPARENT = x; const int WS_EX_LAYERED = x; const int LWA_ALPHA = ; private void Form_Load(object sender EventArgs e) { thisBackColor = ColorSilver; thisTopMost = true; thisFormBorderStyle = FormBorderStyleNone; thisWindowState = FormWindowStateMaximized; SetWindowLong(Handle GWL_EXSTYLE GetWindowLong(Handle GWL_EXSTYLE) | WS_EX_TRANSPARENT | WS_EX_LAYERED); SetLayeredWindowAttributes(Handle LWA_ALPHA ); } } } |