From 2f762cfb545e025e550e523986db3d79ba1fb5fa Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Jul 2020 16:09:24 +1000 Subject: Scale the base width of list view columns according to the DPI. --- src/dutil/inc/thmutil.h | 1 + src/dutil/thmutil.cpp | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/dutil/inc/thmutil.h b/src/dutil/inc/thmutil.h index 41b1e916..c75f9587 100644 --- a/src/dutil/inc/thmutil.h +++ b/src/dutil/inc/thmutil.h @@ -86,6 +86,7 @@ struct THEME_COLUMN { LPWSTR pszName; UINT uStringId; + int nDefaultDpiBaseWidth; int nBaseWidth; int nWidth; BOOL fExpands; diff --git a/src/dutil/thmutil.cpp b/src/dutil/thmutil.cpp index 1c3ae683..b40868a1 100644 --- a/src/dutil/thmutil.cpp +++ b/src/dutil/thmutil.cpp @@ -3137,6 +3137,7 @@ static HRESULT ParseColumns( IXMLDOMNodeList* pixnl = NULL; IXMLDOMNode* pixnChild = NULL; BSTR bstrText = NULL; + DWORD dwValue = 0; hr = XmlSelectNodes(pixn, L"Column", &pixnl); ThmExitOnFailure(hr, "Failed to select child column nodes."); @@ -3152,24 +3153,28 @@ static HRESULT ParseColumns( i = 0; while (S_OK == (hr = XmlNextElement(pixnl, &pixnChild, NULL))) { + THEME_COLUMN* pColumn = pControl->ptcColumns + i; + hr = XmlGetText(pixnChild, &bstrText); ThmExitOnFailure(hr, "Failed to get inner text of column element."); - hr = XmlGetAttributeNumber(pixnChild, L"Width", reinterpret_cast(&pControl->ptcColumns[i].nBaseWidth)); + hr = XmlGetAttributeNumber(pixnChild, L"Width", &dwValue); if (S_FALSE == hr) { - pControl->ptcColumns[i].nBaseWidth = 100; + dwValue = 100; } ThmExitOnFailure(hr, "Failed to get column width attribute."); - hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast(&pControl->ptcColumns[i].fExpands)); + pColumn->nBaseWidth = pColumn->nDefaultDpiBaseWidth = dwValue; + + hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast(&pColumn->fExpands)); if (E_NOTFOUND == hr) { hr = S_OK; } ThmExitOnFailure(hr, "Failed to get expands attribute."); - hr = StrAllocString(&(pControl->ptcColumns[i].pszName), bstrText, 0); + hr = StrAllocString(&pColumn->pszName, bstrText, 0); ThmExitOnFailure(hr, "Failed to copy column name."); ++i; @@ -5495,6 +5500,16 @@ static void ScaleControl( } } + if (THEME_CONTROL_TYPE_LISTVIEW == pControl->type) + { + for (DWORD i = 0; i < pControl->cColumns; ++i) + { + THEME_COLUMN* pColumn = pControl->ptcColumns + i; + + pColumn->nBaseWidth = DpiuScaleValue(pColumn->nDefaultDpiBaseWidth, nDpi); + } + } + pControl->nWidth = DpiuScaleValue(pControl->nDefaultDpiWidth, nDpi); pControl->nHeight = DpiuScaleValue(pControl->nDefaultDpiHeight, nDpi); pControl->nX = DpiuScaleValue(pControl->nDefaultDpiX, nDpi); -- cgit v1.2.3-55-g6feb