Search code examples
c++cwindowswinapigdi

Disable transparency for a "desktop" child window


I pin a window to the desktop by making it a child of the WorkerW window that contains the desktop FolderView in Windows 7 Aero. So far this works perfectly for pinning the window to the desktop, but the window has some sort of transparency which it doesn't has as a topmost window.Instead of a dark background RGB(0,21,32) the actual desktop background/wallpaper shines through

case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps);
    GetClientRect(hWnd, &cr);
    SelectObject(hdc, GetStockObject(DC_BRUSH));
    SetDCBrushColor(hdc, RGB(0,21,32));
    FillRect(hdc, &cr, (HBRUSH) GetStockObject(DC_BRUSH));

The client area is drawn via GDI, i tried everything i could think of to make the window fully opaque: SetBkColor, SetLayeredWindowAttributes, WNDCLASSEX.style = CS_PARENTDC, using RGBA colors (only works to get even more transparency up to 100%, but setting it to opaque doesn't change the outcome)

Is there any way to draw an opaque window as a child of the Aero desktop?


Solution

  • Using Direct2D does the job as intended (100% opaque), as soon as i mix it with GDI (CreateDCRenderTarget or ID2D1GdiInteropRenderTarget) the whole transparency thing comes up again. So much for "Direct2D and GDI Interoperability" Guess it's time to port the legacy GDI code to Direct2D then ....