aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZufu Liu <unknown>2020-05-28 08:13:14 +1000
committerZufu Liu <unknown>2020-05-28 08:13:14 +1000
commit387e6f7794fae7bb65018fb57474c693c03225f7 (patch)
tree84743dda8b8fe25c72222f72732942d16a384d19
parentb9f4eda1baeeffeeee39701db618b4ba7f58eefe (diff)
downloadscintilla-mirror-387e6f7794fae7bb65018fb57474c693c03225f7.tar.gz
Backport: Bug [#2063]. Call AdjustWindowRectExForDpi when available to find correct size.
Backport of changeset 8267:5899b54cc783.
-rw-r--r--win32/PlatWin.cxx24
1 files changed, 16 insertions, 8 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 7854966d1..9f43addca 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -259,10 +259,14 @@ GetDpiForWindowSig fnGetDpiForWindow = nullptr;
using GetSystemMetricsForDpiSig = int(WINAPI *)(int nIndex, UINT dpi);
GetSystemMetricsForDpiSig fnGetSystemMetricsForDpi = nullptr;
+using AdjustWindowRectExForDpiSig = BOOL(WINAPI *)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi);
+AdjustWindowRectExForDpiSig fnAdjustWindowRectExForDpi = nullptr;
+
void LoadDpiForWindow() noexcept {
HMODULE user32 = ::GetModuleHandleW(L"user32.dll");
fnGetDpiForWindow = DLLFunction<GetDpiForWindowSig>(user32, "GetDpiForWindow");
fnGetSystemMetricsForDpi = DLLFunction<GetSystemMetricsForDpiSig>(user32, "GetSystemMetricsForDpi");
+ fnAdjustWindowRectExForDpi = DLLFunction<AdjustWindowRectExForDpiSig>(user32, "AdjustWindowRectExForDpi");
using GetDpiForSystemSig = UINT(WINAPI *)(void);
GetDpiForSystemSig fnGetDpiForSystem = DLLFunction<GetDpiForSystemSig>(user32, "GetDpiForSystem");
@@ -2017,7 +2021,7 @@ class ListBoxX : public ListBox {
HWND GetHWND() const;
void AppendListItem(const char *text, const char *numword);
- static void AdjustWindowRect(PRectangle *rc);
+ static void AdjustWindowRect(PRectangle *rc, UINT dpi);
int ItemHeight() const;
int MinClientWidth() const;
int TextOffset() const;
@@ -2098,7 +2102,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei
hinstanceParent,
this);
- dpi = DpiForWindow(wid);
+ dpi = DpiForWindow(hwndParent);
POINT locationw = POINTFromPoint(location);
::MapWindowPoints(hwndParent, NULL, &locationw, 1);
location = PointFromPOINT(locationw);
@@ -2168,7 +2172,7 @@ PRectangle ListBoxX::GetDesiredRect() {
if (Length() > rows)
rcDesired.right += SystemMetricsForDpi(SM_CXVSCROLL, dpi);
- AdjustWindowRect(&rcDesired);
+ AdjustWindowRect(&rcDesired, dpi);
return rcDesired;
}
@@ -2179,7 +2183,7 @@ int ListBoxX::TextOffset() const {
int ListBoxX::CaretFromEdge() {
PRectangle rc;
- AdjustWindowRect(&rc);
+ AdjustWindowRect(&rc, dpi);
return TextOffset() + static_cast<int>(TextInset.x + (0 - rc.left) - 1);
}
@@ -2377,9 +2381,13 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) {
SetRedraw(true);
}
-void ListBoxX::AdjustWindowRect(PRectangle *rc) {
+void ListBoxX::AdjustWindowRect(PRectangle *rc, UINT dpi) {
RECT rcw = RectFromPRectangle(*rc);
- ::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE);
+ if (fnAdjustWindowRectExForDpi) {
+ fnAdjustWindowRectExForDpi(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE, dpi);
+ } else {
+ ::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE);
+ }
*rc = PRectangle::FromInts(rcw.left, rcw.top, rcw.right, rcw.bottom);
}
@@ -2398,7 +2406,7 @@ int ListBoxX::MinClientWidth() const {
POINT ListBoxX::MinTrackSize() const {
PRectangle rc = PRectangle::FromInts(0, 0, MinClientWidth(), ItemHeight());
- AdjustWindowRect(&rc);
+ AdjustWindowRect(&rc, dpi);
POINT ret = {static_cast<LONG>(rc.Width()), static_cast<LONG>(rc.Height())};
return ret;
}
@@ -2409,7 +2417,7 @@ POINT ListBoxX::MaxTrackSize() const {
maxCharWidth * maxItemCharacters + static_cast<int>(TextInset.x) * 2 +
TextOffset() + SystemMetricsForDpi(SM_CXVSCROLL, dpi)),
ItemHeight() * lti.Count());
- AdjustWindowRect(&rc);
+ AdjustWindowRect(&rc, dpi);
POINT ret = {static_cast<LONG>(rc.Width()), static_cast<LONG>(rc.Height())};
return ret;
}