From 995ed049cba280c4e791cd35118e8e6e2766a185 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sun, 17 Dec 2023 09:01:59 +0800 Subject: [PATCH] Revert "Do not limit the max window size (#2889) (#3142)" This reverts commit fe80dc6ca6fb873fb847c165adc5578ee65a58b4. --- src/slic3r/GUI/MainFrame.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 676dbc78ee..c8dad01b4a 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -395,6 +395,34 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ update_layout(); sizer->SetSizeHints(this); +#ifdef WIN32 + auto setMaxSize = [this]() { + wxDisplay display(this); + auto size = display.GetClientArea().GetSize(); + HWND hWnd = GetHandle(); + RECT borderThickness; + SetRectEmpty(&borderThickness); + AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0); + SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom}); + }; + this->Bind(wxEVT_DPI_CHANGED, [setMaxSize](auto & e) { + setMaxSize(); + e.Skip(); + }); + setMaxSize(); + // SetMaximize already position window at left/top corner, even if Windows Task Bar is at left side. + // Not known why, but fix it here + this->Bind(wxEVT_MAXIMIZE, [this](auto &e) { + wxDisplay display(this); + auto pos = display.GetClientArea().GetPosition(); + HWND hWnd = GetHandle(); + RECT borderThickness; + SetRectEmpty(&borderThickness); + AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0); + Move(pos + wxPoint{borderThickness.left, borderThickness.top}); + e.Skip(); + }); +#endif // WIN32 // BBS Fit();