【发布时间】:2023-03-17 04:00:01
【问题描述】:
在 Windows 窗体和 C# 中,我使用具有 WS_EX_LAYERED 样式的窗体,并调用 UpdateLayeredWindow 将背景设置为透明/alpha 混合的图像:
NativeMethods.BLENDFUNCTION blend = new NativeMethods.BLENDFUNCTION();
blend.BlendOp = NativeMethods.AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = NativeMethods.AC_SRC_ALPHA;
NativeMethods.UpdateLayeredWindow(form.Handle, screenDc, ref topPos, ref size,
memDc, ref pointSource, 0, ref blend, NativeMethods.ULW_ALPHA);
在图像透明的窗体区域上,窗体不接收鼠标事件。他们转到表单下方的窗口。
是否可以设置窗口样式或选项以使表单能够在其整个表面上接收鼠标事件(鼠标移动、鼠标按下等)?
【问题讨论】:
标签: c# .net winforms alphablending layered-windows