I need to create a borderless window with specified background color. I know how to remove a non client area and get something like this:
It's cool but not truly what I want. If you take a closer look at any aero window - there's a shadow around it (actually this is not a shadow but some glow). I found somewhere that I can use this code to add a shadow:
const MARGINS shadow_on = { 1, 1, 1, 1 };
DwmExtendFrameIntoClientArea(hwnd, &shadow_on);
It's almost do it's job (thought this is absolutely not clear to me - documentation says nothing about relationship of shadow and this function). Almost. There's a thin border appeared around the window. It looks like it's semitransparent and it breaks the look and feel of the window:
I know that it's possible - the visual studio even change the color of this border somehow!
Update: as IInspectable noticed in comments I can use negative margins in DwmExtendFrameIntoClientArea()
. I set -1 value and got this result:
As you can see - it's even weirder. I tried to fill a background with color, but without luck.
CS_DROPSHADOW
in class style? – PrecariousDwmExtenFrameIntoClientArea
with negative margin values turns the entire client area into Aero Glass. Have you tried using a margin with all members set to zero? – AzazelCS_DROPSHADOW
not it? – AccelerometerCS_DROPSHADOW
adds shadow near bottom and right window edges only. Anyway, I found how to achieve what I want: 1.CreateWindowEx
withWS_EX_LAYERED
flag. 2. callSetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 0, LWA_COLORKEY);
- the color should differ from window's background (specified inWNDCLASSEX
). 3. callDwmExtendFrameIntoClientArea()
with margins where at least one margin not zero. – Verbenia