FIX: [STUDIO-2702] fix maximize size offset, ad7bda2

Change-Id: I4f65ef25dc4241bf7c1c3d15c38198ea2b40b337
This commit is contained in:
chunmao.guo 2023-05-18 20:23:49 +08:00 committed by Lane.Wei
parent 9352f34ad0
commit c770926142
2 changed files with 21 additions and 14 deletions

View file

@ -384,18 +384,27 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
auto setMaxSize = [this]() {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
// 8 pixels shadow
SetMaxSize(size + wxSize{16, 16});
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();
Move(pos - wxPoint{8, 8});
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