I'd like to have the same effect as the windows 7 taskbar.
I've looked in this question:
Keep Window Looking Active
It works great but only if the window has a non-client area.
My window is border-less and the content of it (just a black background) is rendered as it is inactive, no matter what I do.
I've set my window flags just as Windows 7 taskbar but it didn't help.
My only thought at the moment is to draw it with borders and just clip them, is there a better way to achieve what I want?
EDIT 1:
Clipping didn't work, after clipping the borders the window content was rendered as inactive window.
How the hell does windows 7 task-bar works then?
EDIT2:
Adding some photos to explain myself better, The following window content is a black background.
That's an inactive window (the content is rendered kinda dark):
That's an active window:
If the window has no client area the content is always rendered as inactive window however the windows Taskbar is always rendered as active window and it doesn't have any NC area (at least according to spy++). That's what I'm trying to mimic.
EDIT3:
Sharing my recent discoveries.
explorer.exe main window is frameless and has the following flags:
I dived into the explorer's process dwmapi.dll exported functions:
it uses DwmEnableBlurBehindWindow, just as I do.
I've checked the undocumented ordinal functions and none of them is related to rendering the aero glass as active.
Could it be the DWM rules don't apply to explorer?
Tricky one..
set the NCRenderingPolicy to Enabled with the "DwmSetWindowAttribute" API.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa969524(v=vs.85).aspx
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[Flags]
public enum DwmWindowAttribute
{
NCRenderingEnabled = 1,
NCRenderingPolicy,
TransitionsForceDisabled,
AllowNCPaint,
CaptionButtonBounds,
NonClientRtlLayout,
ForceIconicRepresentation,
Flip3DPolicy,
ExtendedFrameBounds,
HasIconicBitmap,
DisallowPeek,
ExcludedFromPeek,
Last
}
[Flags]
public enum DwmNCRenderingPolicy
{
UseWindowStyle,
Disabled,
Enabled,
Last
}
public static bool SetNCRenderingActive(IntPtr Handle)
{
int renderPolicy = (int)DwmNCRenderingPolicy.Enabled;
return (DwmSetWindowAttribute(Handle, (int)DwmWindowAttribute.NCRenderingPolicy, ref renderPolicy, sizeof(int) ) == 0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With