After using DWM, the button text becomes transparent

I am using plain C and here is the code:

Creating a button:

HWND hBTN = CreateWindow(_T("button"), _T("AAasfasdfdsa"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 10, 10, 100, 100, hWnd, NULL, hInst, NULL);

      

Calling the DWM function:

DWM_BLURBEHIND bb = { 0 };
bb.dwFlags = DWM_BB_ENABLE;
bb.fEnable = true;
bb.hRgnBlur = NULL;
MARGINS margins = { -1, -1, -1, -1 };
DwmExtendFrameIntoClientArea(hWnd, &margins);

      

the image demonstrates:

enter image description here

+3


source to share


1 answer


The text becomes transparent because black is treated as a transparency key.

Therefore, you just need to set another transparency key for the window:



SetWindowLong(hWnd,GWL_EXSTYLE,WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd,RGB(200,201,202),0,LWA_COLORKEY);

      

0


source







All Articles