我想创建一个透明窗口,里面有不透明的对象,我正在使用此代码 `
bool nBOOL = true;
HRESULT hr = S_OK;
LRESULT nRet = S_OK;
HRGN hRgnBlur = 0;
DWM_BLURBEHIND bb = {0};
// Create and populate the BlurBehind structure.
// Set Blur Behind and Blur Region.
bb.fEnable = nBOOL; //true
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
bb.fTransitionOnMaximized = 0;
// Fool DWM with a fake region
if (nBOOL) { hRgnBlur = CreateRectRgn(-1, -1, 0, 0); }
bb.hRgnBlur = hRgnBlur;
// Set Blur Behind mode.
nRet = DwmEnableBlurBehindWindow(HWnd, &bb);
HBRUSH brush = CreateSolidBrush(RGB(0, 0, 255));
SetClassLongPtr(HWnd, GCLP_HBRBACKGROUND, (LONG_PTR)brush);
`
问题在于,绘制对象时,渲染目标正在使用方法getbackgroundcolor(),该方法返回null或alpha 0的背景,从而导致渲染问题(对象看起来不正常)。