Recently I discovered how to get Aero Blur to work in borderless Forms across Windows Vista, 7 and 10. I am achieving this using the following function:
private void UpdateAeroBlur() {
if (!SupportsAeroBlur) //do not do anything if XP or older
return;
else if (useSetWindowComposition) { //true if SetWindowCompositionAttribute function
//exists in user32.dll
AccentPolicy accent = new AccentPolicy();
accent.AccentState = enableAeroBlur ? AccentState.ENABLE_BLURBEHIND : AccentState.DISABLED;
WindowCompositionAttributeData data = new WindowCompositionAttributeData();
data.Attribute = DwmWindowAttribute.ACCENT_POLICY;
data.SizeOfData = AccentPolicy.Size;
unsafe
{
data.Data = new IntPtr(&accent);
}
NativeApi.SetWindowCompositionAttribute(Handle, ref data);
}
DWM_BLURBEHIND style = new DWM_BLURBEHIND() {
dwFlags = DWM_BB.Enable,
fEnable = true
};
NativeApi.DwmEnableBlurBehindWindow(Handle, ref style);
}
And it manages to make the border of my custom Form translucent! However I am getting an annoying side-effect.
Look at this:
The text in the TextBox controls has become transparent, while the text on the buttons which are drawn using anti-aliased text GDI+ are not transparent.
I tried calling SetLayeredWindowAttributes and tried LWA_ALPHA
with bAlpha = 255
and then tried LWA_COLORKEY
with a COLORREF
zeroed out, but the issue remained.
How do I make the text in TextBox controls opaque while leaving the border translucent?