ARTICLE AD BOX


I’m building a Win32 desktop app (C++), with a WebView2 child filling the client area. I want a window with:
No default caption/title bar and no system buttons (min/max/close) Still resizable using the native DWM sizing frame A thin visible frame (ideally ~1px) on all sides Normal minimize/maximize/restore animations (like a regular overlapped window)The screenshots are Windows 11, but ideally I want the same behavior for Windows 10.
Currently, I use a very ugly solution that works on Windows 11 properly, except the resize area for the top border is only 1px, and it's broken on Windows 10:
case WM_NCCALCSIZE: { if (wparam == TRUE) { NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(lparam); RECT original = params->rgrc[0]; LRESULT result = DefWindowProc(hwnd, msg, wparam, lparam); params->rgrc[0] = original; int pad = GetSystemMetrics(SM_CXPADDEDBORDER); int frame = GetSystemMetrics(SM_CXSIZEFRAME); if (IsZoomed(hwnd)) { int total = frame + pad; params->rgrc[0].top += total; params->rgrc[0].bottom -= total; params->rgrc[0].left += total; params->rgrc[0].right -= total; } else { params->rgrc[0].top += 1; params->rgrc[0].bottom -= pad; params->rgrc[0].left += pad; params->rgrc[0].right -= pad; } return result; } break; }
The solution works on my Windows 11 machine as I said, but when I tested on a Windows 10 machine, it had the default Windows top bar controls + a weird 1px padding on the left of the Window.
In the hacky but somewhat working solution I showed above, I use the following creation flags:
window_ = CreateWindowExW(WS_EX_APPWINDOW, WINDOW_CLASS_NAME, L"WinRAT Server Control Panel", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 800, nullptr, nullptr, GetModuleHandle(nullptr), this); if (!window_) { return false; } SetWindowPos(window_, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); ShowWindow(window_, SW_SHOWNORMAL); UpdateWindow(window_);So now, I'm wondering if there's a proper intended solution to do this that will work on both Win10/11?
