Desktop Window Manager (DWM) problem
-
I am using the Microsoft DWM (Desktop Window Manager), and I am using the DwmEnableBlurBehindWindow() function with the WS_EX_LAYERED style.. however, the window renders fine initially, but then when i move the window, it goes all weird and doesnt display the window properly and just displays the window icon and a garbled up title bar about 50pixels wide and 10pixels high.. heres the code: --- HRESULT EnableBlurBehindWindow(HWND window, bool enable = true, HRGN region = 0, bool transitionOnMaximized = false) { DWM_BLURBEHIND blurBehind = { 0 }; blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED; blurBehind.fEnable = enable; blurBehind.fTransitionOnMaximized = transitionOnMaximized; if (enable && 0 != region) { blurBehind.dwFlags |= DWM_BB_BLURREGION; blurBehind.hRgnBlur = region; } return DwmEnableBlurBehindWindow(window, &blurBehind); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); EnableBlurBehindWindow(hwnd); } break; case WM_ERASEBKGND: { RECT clientRect; GetClientRect(hwnd, &clientRect); SelectObject((HDC)wParam, GetStockObject(BLACK_BRUSH)); Rectangle((HDC)wParam, 0, 0, clientRect.right, clientRect.bottom); } break; case WM_CLOSE: EndDialog(hwnd, 0); break; } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)WndProc); return 0; } --- Is there any further message processing I need to do or anything..? Thanks for your help! --PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
-
I am using the Microsoft DWM (Desktop Window Manager), and I am using the DwmEnableBlurBehindWindow() function with the WS_EX_LAYERED style.. however, the window renders fine initially, but then when i move the window, it goes all weird and doesnt display the window properly and just displays the window icon and a garbled up title bar about 50pixels wide and 10pixels high.. heres the code: --- HRESULT EnableBlurBehindWindow(HWND window, bool enable = true, HRGN region = 0, bool transitionOnMaximized = false) { DWM_BLURBEHIND blurBehind = { 0 }; blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED; blurBehind.fEnable = enable; blurBehind.fTransitionOnMaximized = transitionOnMaximized; if (enable && 0 != region) { blurBehind.dwFlags |= DWM_BB_BLURREGION; blurBehind.hRgnBlur = region; } return DwmEnableBlurBehindWindow(window, &blurBehind); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); EnableBlurBehindWindow(hwnd); } break; case WM_ERASEBKGND: { RECT clientRect; GetClientRect(hwnd, &clientRect); SelectObject((HDC)wParam, GetStockObject(BLACK_BRUSH)); Rectangle((HDC)wParam, 0, 0, clientRect.right, clientRect.bottom); } break; case WM_CLOSE: EndDialog(hwnd, 0); break; } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)WndProc); return 0; } --- Is there any further message processing I need to do or anything..? Thanks for your help! --PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
I don't think you should use
WS_EX_LAYERED
and glass together. They are two different ways of creating transparency.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
I don't think you should use
WS_EX_LAYERED
and glass together. They are two different ways of creating transparency.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Thanks for your help :) --PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates