I am having problems expanding window frames using DwmExtendFrameIntoClientArea on Windows 10. The images below show the behavior that I get

The white color of the title bar is enlarged from above, and from the sides and from below - the colored edge of the window.
If I set all the fields to -1 to completely break the frames, the window fills with white and completely loses its color edge:

This result is very incompatible, I expected that the white color will expand on all sides of the window, similar to how the color frame expands in Windows 8, or the glass expands in Windows 7 and Vista.
I tried searching on the Internet, but I could not find such problems.
Here is the code I'm using:
#include <windows.h> #include <dwmapi.h> #include <stdio.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int main(int argc, char **argv) { HINSTANCE hInstance = GetModuleHandle(NULL); MSG msg; HWND hwnd; WNDCLASSW wc; int message; wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpszClassName = L"Window"; wc.hInstance = hInstance; wc.hbrBackground = GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpfnWndProc = WndProc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); RegisterClassW(&wc); hwnd = CreateWindowW(wc.lpszClassName, L"Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 350, 250, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); while(1) { message = GetMessageW(&msg, NULL, 0, 0); if(message == -1) { char x[100]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), x, 100, NULL); puts(x); abort(); } else if(message == 0) break; TranslateMessage(&msg); DispatchMessageW(&msg); } return (int) msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_ACTIVATE: { MARGINS m = {50, 50, 50, 50}; HRESULT hr = DwmExtendFrameIntoClientArea(hwnd, &m); if(!SUCCEEDED(hr)) { char x[100]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), x, 100, NULL); puts(x); abort(); } break; } case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProcW(hwnd, msg, wParam, lParam); }
Am I doing something wrong or is it just a problem with Windows 10? Thanks in advance for your help!
Edit: The code I posted works fine with both Aero Lite and high contrast themes in Windows 10, but not with the default Windows 10 theme.