diff --git a/uppsrc/CtrlCore/Win32Ctrl.h b/uppsrc/CtrlCore/Win32Ctrl.h index bb1ab9c07..9f2e7a3c9 100644 --- a/uppsrc/CtrlCore/Win32Ctrl.h +++ b/uppsrc/CtrlCore/Win32Ctrl.h @@ -45,6 +45,9 @@ protected: void Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow); Image DoMouse(int e, Point p, int zd = 0); + Rect AdjustWindowRect(const Rect& client, dword style, dword exstyle); + Rect AdjustWindowRect(const Rect& client); + void PaintWinBarBackground(SystemDraw& w, const Rect& clip); void PaintWinBar(SystemDraw& w, const Rect& clip); int GetActiveTitleBarButton(); diff --git a/uppsrc/CtrlCore/Win32Proc.cpp b/uppsrc/CtrlCore/Win32Proc.cpp index 7c93666b6..7d01546db 100644 --- a/uppsrc/CtrlCore/Win32Proc.cpp +++ b/uppsrc/CtrlCore/Win32Proc.cpp @@ -896,16 +896,8 @@ LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { MINMAXINFO *mmi = (MINMAXINFO *)lParam; Rect frmrc = Size(200, 200); ::AdjustWindowRect(frmrc, WS_OVERLAPPEDWINDOW, FALSE); -// Size msz = Ctrl::GetWorkArea().Deflated(-frmrc.left, -frmrc.top, -// frmrc.right - 200, frmrc.bottom - 200).GetSize(); -// Rect minr(Point(50, 50), min(msz, GetMinSize())); -// Rect maxr(Point(50, 50), min(msz, GetMaxSize())); // Removed cxl&nixnixnix 2012-6-12 - Rect minr(Point(50, 50), GetMinSize()); - Rect maxr(Point(50, 50), GetMaxSize()); - dword style = ::GetWindowLong(hwnd, GWL_STYLE); - dword exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE); - AdjustWindowRectEx(minr, style, FALSE, exstyle); - AdjustWindowRectEx(maxr, style, FALSE, exstyle); + Rect minr = AdjustWindowRect(Rect(Point(50, 50), GetMinSize())); + Rect maxr = AdjustWindowRect(Rect(Point(50, 50), GetMaxSize())); mmi->ptMinTrackSize = Point(minr.Size()); mmi->ptMaxTrackSize = Point(maxr.Size()); LLOG("WM_GETMINMAXINFO: MinTrackSize = " << Point(mmi->ptMinTrackSize) << ", MaxTrackSize = " << Point(mmi->ptMaxTrackSize)); diff --git a/uppsrc/CtrlCore/Win32Wnd.cpp b/uppsrc/CtrlCore/Win32Wnd.cpp index db7141204..39a3778c6 100644 --- a/uppsrc/CtrlCore/Win32Wnd.cpp +++ b/uppsrc/CtrlCore/Win32Wnd.cpp @@ -472,14 +472,40 @@ void Ctrl::UseImmersiveDarkModeForWindowBorder() } } +Rect Ctrl::AdjustWindowRect(const Rect& client, dword style, dword exstyle) +{ + Rect r = client; + TopWindow *tw = dynamic_cast(this); + if(tw && tw->custom_bar_frame) { + Rect mr(100, 100, 200, 200); + AdjustWindowRectEx(mr, style, FALSE, exstyle); + + r.left -= (100 - mr.left); + r.right += (mr.right - 200); + r.bottom += (mr.bottom - 200); + + r.top -= tw->GetCustomTitleBarMetrics().height; + } + else + AdjustWindowRectEx(r, style, FALSE, exstyle); + + return r; +} + +Rect Ctrl::AdjustWindowRect(const Rect& client) +{ + HWND hwnd = GetHWND(); + return hwnd ? AdjustWindowRect(client, ::GetWindowLong(hwnd, GWL_STYLE), ::GetWindowLong(hwnd, GWL_EXSTYLE)) + : client; +} + void Ctrl::Create(HWND parent, DWORD style, DWORD exstyle, bool savebits, int show, bool dropshadow) { GuiLock __; ASSERT_(IsMainThread(), "Window creation can only happen in the main thread"); LLOG("Ctrl::Create(parent = " << (void *)parent << ") in " <