I'm having some trouble extending the window frames using DwmExtendFrameIntoClientArea
on Windows 10. The images below show the behaviour I'm getting:
The white titlebar colour is extended from the top, while from the sides and the bottom it extends the coloured edge of the window.
If I set the margins all to -1
to extend the frames all the way, the window is filled with white and loses its coloured edge altogether:
This result is very inconsistent, I was expecting the white colour to be extended on all sides of the window, similar to the way the coloured frame is extended in Windows 8, or the glass is extended in Windows 7 and Vista.
I've tried searching online, but I haven't been able to find any similar issues.
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 this just an issue with Windows 10? Thanks in advance for any help!
Edit: The code I posted works perfectly with both Aero Lite and the high contrast themes on Windows 10, but not with the default Windows 10 theme.