Skip to content

Commit

Permalink
Fixed a non-resizable window issue[#428] (#429)
Browse files Browse the repository at this point in the history
Non-resizable window appears with white borders when they are created and moved.
I found that the reason is that the code does not notify the system when the border style of the window's frame is changed.
  • Loading branch information
zhkkjun authored and djowel committed Oct 27, 2024
1 parent 88eee1a commit b25c7a4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/host/windows/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,23 @@ namespace cycfi::elements
void disable_minimize(HWND hwnd)
{
SetWindowLongW(hwnd, GWL_STYLE,
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX);
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX);
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
}

[[maybe_unused]]
void disable_maximize(HWND hwnd)
{
SetWindowLongW(hwnd, GWL_STYLE,
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX);
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_MAXIMIZEBOX);
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
}

void disable_resize(HWND hwnd)
{
SetWindowLongW(hwnd, GWL_STYLE,
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX);
disable_maximize(hwnd);
GetWindowLongW(hwnd, GWL_STYLE) & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX);
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
}

LRESULT on_close(window* win)
Expand Down

0 comments on commit b25c7a4

Please sign in to comment.