I'm having problems drawing Windows 10 themed Window Caption Buttons using the VisualStyleRenderer class.
My problem is that I can't figure out which Theme Class to use.
I tried Window
and CompositedWindow::Window
, however, none of those actually contain Windows 10 themed buttons as I found out using this msstyle editor.
Which Theme Class contains Windows 10 themed Caption Buttons?
How it looks now:
How I want it to look:
How I'm drawing the buttons:
protected override void OnPaint(PaintEventArgs e)
{
VisualStyleRenderer renderer = new VisualStyleRenderer("Window", 18 /*WP_CLOSEBUTTON*/, 1 /*CBS_NORMAL*/);
var size = renderer.GetPartSize(e.Graphics, ThemeSizeType.True);
renderer.DrawBackground(e.Graphics, new System.Drawing.Rectangle(10, 10, size.Width, size.Height));
}
The problem is the Window
class you are using. This is the legacy GDI Window that is composited without a composition engine.
The DWM
Desktop Window Manager composites every window, as every window is just a DirectX surface. You need to use the DWMWindow
class as opposed to the Window
class from aero.msstyles
.
Notice how there are multiple glyphs for each DPI: 96, 120, 144, etc.