In progress: This page is still being researched. I’ll be adding more info as I go. But there’s already some value so enjoy if you’re into this stuff…
The goal is to replace the Windows own window chrome / non-client area / border while maintaining compatibility with layout snapping features in both Windows 10 and Windows 11.
- Windows 10 and Windows 11:
Win+Up
shortcut to maximize window.
Win+Down
shortcut to restore/minimize window.
Win+Left
and Win+Right
to snap the window to left/right side of the monitor.
- Dragging the window to snap it to monitor areas.
- Resizing the window
- Windows 11:
- Snap Layout overlay to be shown when you hover over the maximize button.
Introduction to the chore
Following steps are generally involved:
- Create window with the right window flags.
- Call
DwmExtendFrameIntoClientArea
that extends the client area for DWM.
- Implement handler for
WM_NCCALCSIZE
that extends the client area for Win32.
- This is also requires us to tell the OS that we are going to change the chrome when window is created by calling
ShowWindowPos
from WM_CREATE
.
- Implement handler for
WM_HITTEST
to inform Windows where your own chrome controls are.
- Implement message handlers for mouse to handle the controls interaction.
- Work around random parts of either Windows 95 or Windows 7 portions of the chrome being rendered.
Nearly every step mentioned above has it’s own parameters and annoyances and they do affect each other in some cases. Here are some known correlations:
- Window flags have to be right. For example
Win+Up
shortcut or Snap Layout popup won’t work if the window doesn’t have WS_MAXIMIZEBOX
style.
DwmExtendFrameIntoClientArea
and WM_NCCALCSIZE
are closely related to each other and result in most variants. The test bed basically focuses on these two and permutations of individual known or unknown setups.
Known regressions
The goal is to ideally not have any of following known regressions happening. (This is list a result of my own manual testing, and there might be more things I simply don’t know about.)
- Visual regressions: (we can detect these just by looking at a screenshot or video)
- Standard chrome is shown fully.
- Standard chrome is partially shown (a single border).
- Shadow (and rounded corners) are not rendered.
- Shadow darkness/depth differs.
- Original minimize/maximize/close icons are still shown without background.
- Window doesn’t have correct size.
- Content is not drawn in the window.
- Start-up window animation is not correct.
- Functional regressions: (we can detect these only with interacting with windows)
- Resize areas are too small.
- Resize areas are not even (some don’t work).
- Snap Layout doesn’t show at all when Maximize button is hovered.
- Snap Layout doesn’t show when only a portion of the area of the Maximize button is hovered.
- Tooltips don’t show.
- Click on the buttons only works on small area of close button only.
- Click on the buttons only works on “half” of the button area.
- Click on the buttons shows Windows 95-style version of the clicked button.
- Click on the buttons shows Windows 7-style version of the clicked button.
- Click on the NC area shows Windows 7-style chrome around the entire window.