Messing around with the Win32 API and I have this ugly white border around it when I apply styling to it that makes the window unresizable. How do I remove the border while still making the window unresizable?
void windowSetResizable(Window* window, bool canResize) {
InternalWindow* internalWindow = getInternalWindow(window);
int style = GetWindowLongPtr(internalWindow->handle, GWL_STYLE);
if (!canResize) {
SetWindowLongPtrA(internalWindow->handle, GWL_STYLE, style & ~(WS_THICKFRAME | WS_MAXIMIZEBOX | WS_EX_DLGMODALFRAME));
} else {
SetWindowLongPtrA(internalWindow->handle, GWL_STYLE, style | (WS_THICKFRAME | WS_MAXIMIZEBOX));
}
}
After a bit of playing around with the code provided by @adrid, I was able to resolve it by simply stripping WS_THICKFRAME and WS_MAXIMIZEBOX from the Window style.
If WS_BORDER is also stripped, the window can't have a title bar which is not explicitly stated in the documentation. Below shows a before and after.
Final Code:
void windowSetResizable(Window* window, bool canResize) {
InternalWindow* internalWindow = getInternalWindow(window);
int style = GetWindowLongPtr(internalWindow->handle, GWL_STYLE);
if (!canResize) {
style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
} else {
style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
}
SetWindowLongPtrA(internalWindow->handle, GWL_STYLE, style);
SetWindowPos(internalWindow->handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}