When I remove the sizing border of a window, it leaves black areas around it.
Is it possible to somehow tell the window to occupy/paint these areas, as there's no sizing border anymore?
A reproducible example: launch a instance of chrome browser with:
chrome.exe -app=https://www.google.com
Remove the sizing border:
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
lStyle &= ~(WS_THICKFRAME | WS_DLGFRAME);
SetWindowLong(hwnd, GWL_STYLE, lStyle);
WS_THICKFRAME
0x00040000L
The window has a sizing border. Same as the WS_SIZEBOX style.WS_DLGFRAME
0x00400000L
The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar.
The black areas im talking about: left, right, bottom.
As suggested, I use SetWindowPos() with SWP_FRAMECHANGED, but it didn't result in any visible change.
int flags = SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED;
SetWindowPos(hWnd, 0, 0, 0, 0, 0, flags);
Code:
#include <iostream>
#include <windows.h>
int main()
{
HWND hwnd = FindWindowW( L"Chrome_WidgetWin_1", nullptr );
//HWND hwnd = FindWindowW( L"Notepad", nullptr );
std::cout << "hwnd: " << hwnd << "\n";
LONG lStyle = GetWindowLong( hwnd, GWL_STYLE );
lStyle &= ~( WS_THICKFRAME | WS_DLGFRAME );
SetWindowLong( hwnd, GWL_STYLE, lStyle );
int flags = SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED;
auto swp = SetWindowPos( hwnd, 0, 0, 0, 0, 0, flags );
std::cout << "swp: " << swp << "\n";
}

