by Richard Russell, June 2016

In Windows Vista and Windows 7, by default, the title bar and other non-client areas of a window are translucent, and the background shows through to a degree (albeit blurred). This Aero Glass effect can be quite attractive, and many people were upset when it was removed in Windows 8 and Windows 10, but occasionally it can make it harder to read the window's title text.

If you prefer all window titles and borders to be opaque you can change the setting in 'Control Panel... Personalization... Window Color... Enable Transparency' but you may instead wish just to affect your own program. The code listed below disables transparency for the specified window:

    nomainwin
    open "Opaque Window Title" for window as #w
    #w "trapclose quit"
 
    struct policy, n as long
    l = len(policy.struct)
    policy.n.struct = 1 ' disable transparency
 
    hw = hwnd(#w)
    open "dwmapi.dll" for dll as #dwm
    calldll #dwm, "DwmSetWindowAttribute", hw as ulong, 2 as long, _
                    policy as struct, l as long, r as long
 
    wait
 
sub quit h$
    close #dwm
    close #h$
    end
end sub