Solved.https://blog.csdn.net/baidu_38494049/article/details/140501589?spm=1001.2014.3001.5501
Why SetWindowCompositionAttribute makes text also transparent
When I called SetWindowCompositionAttribute
to make the main window blurred, text of controls on it also became transparent and thus hard to read.
I want to keep the text pure black without transparency while the main window is blurred and transparent. How could I achieve that?
By the way, I found that seemingly all black pixels on the window will become transparent (I set the background of the main window to black so that u can find it transparent in the pic) when SetWindowCompositionAttribute
is called, that all white pixels will keep opaque and that other colors will be semi-transparent with a bit of its original color (see the bottommost control in the pic above, which is a Syslink and originally blue). Hope this will be helpful to you guys.
The code fragment in which I call the API:
DWORD accent[4] = { 3,0,0,0 }; // 3 means AccentState=ACCENT_ENABLE_BLURBEHIND
struct {
DWORD attrib;
PVOID pvData;
UINT cbData;
} AttribData = {19,accent,sizeof(accent)}; // 19 is WCA_ACCENT_POLICY
SetWindowCompositionAttribute(m_hWnd, &AttribData); // m_hWnd is my main window