Scale the base width of list view columns according to the DPI.
Sean Hall committed
Jul 6, 2020 at 16:09 UTC
2f762cfb545e025e550e523986db3d79ba1fb5fa
2 files changed
+20
-4
src/dutil/inc/thmutil.h
+1
@@ -86,6 +86,7 @@ struct THEME_COLUMN
86
{
87
LPWSTR pszName;
88
UINT uStringId;
89
+ int nDefaultDpiBaseWidth;
90
int nBaseWidth;
91
int nWidth;
92
BOOL fExpands;
src/dutil/thmutil.cpp
+19
-4
@@ -3137,6 +3137,7 @@ static HRESULT ParseColumns(
3137
IXMLDOMNodeList* pixnl = NULL;
3138
IXMLDOMNode* pixnChild = NULL;
3139
BSTR bstrText = NULL;
3140
+ DWORD dwValue = 0;
3141
3142
hr = XmlSelectNodes(pixn, L"Column", &pixnl);
3143
ThmExitOnFailure(hr, "Failed to select child column nodes.");
@@ -3152,24 +3153,28 @@ static HRESULT ParseColumns(
3153
i = 0;
3154
while (S_OK == (hr = XmlNextElement(pixnl, &pixnChild, NULL)))
3155
{
3156
+ THEME_COLUMN* pColumn = pControl->ptcColumns + i;
3157
+
3158
hr = XmlGetText(pixnChild, &bstrText);
3159
ThmExitOnFailure(hr, "Failed to get inner text of column element.");
3160
3158
- hr = XmlGetAttributeNumber(pixnChild, L"Width", reinterpret_cast<DWORD*>(&pControl->ptcColumns[i].nBaseWidth));
3161
+ hr = XmlGetAttributeNumber(pixnChild, L"Width", &dwValue);
3162
if (S_FALSE == hr)
3163
{
3161
- pControl->ptcColumns[i].nBaseWidth = 100;
3164
+ dwValue = 100;
3165
}
3166
ThmExitOnFailure(hr, "Failed to get column width attribute.");
3167
3165
- hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast<BOOL*>(&pControl->ptcColumns[i].fExpands));
3168
+ pColumn->nBaseWidth = pColumn->nDefaultDpiBaseWidth = dwValue;
3169
+
3170
+ hr = XmlGetYesNoAttribute(pixnChild, L"Expands", reinterpret_cast<BOOL*>(&pColumn->fExpands));
3171
if (E_NOTFOUND == hr)
3172
{
3173
hr = S_OK;
3174
}
3175
ThmExitOnFailure(hr, "Failed to get expands attribute.");
3176
3172
- hr = StrAllocString(&(pControl->ptcColumns[i].pszName), bstrText, 0);
3177
+ hr = StrAllocString(&pColumn->pszName, bstrText, 0);
3178
ThmExitOnFailure(hr, "Failed to copy column name.");
3179
3180
++i;
@@ -5495,6 +5500,16 @@ static void ScaleControl(
5500
}
5501
}
5502
5503
+ if (THEME_CONTROL_TYPE_LISTVIEW == pControl->type)
5504
+ {
5505
+ for (DWORD i = 0; i < pControl->cColumns; ++i)
5506
+ {
5507
+ THEME_COLUMN* pColumn = pControl->ptcColumns + i;
5508
+
5509
+ pColumn->nBaseWidth = DpiuScaleValue(pColumn->nDefaultDpiBaseWidth, nDpi);
5510
+ }
5511
+ }
5512
+
5513
pControl->nWidth = DpiuScaleValue(pControl->nDefaultDpiWidth, nDpi);
5514
pControl->nHeight = DpiuScaleValue(pControl->nDefaultDpiHeight, nDpi);
5515
pControl->nX = DpiuScaleValue(pControl->nDefaultDpiX, nDpi);