Andrew Eikum : shell32: Size ShellView column widths by font width.
Alexandre Julliard
julliard at winehq.org
Fri Nov 10 17:21:28 CST 2017
Module: wine
Branch: master
Commit: db1a3c617e46c4feac69a587a76c7d9b6d91b14c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=db1a3c617e46c4feac69a587a76c7d9b6d91b14c
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Fri Nov 10 08:28:48 2017 -0600
shell32: Size ShellView column widths by font width.
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/shlview.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index e0dbc3b..1628ea3 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -385,6 +385,9 @@ static void ShellView_InitList(IShellViewImpl *This)
SHELLDETAILS sd;
WCHAR nameW[50];
HRESULT hr;
+ HFONT list_font, old_font;
+ HDC list_dc;
+ TEXTMETRICW tm;
TRACE("(%p)\n", This);
@@ -406,6 +409,13 @@ static void ShellView_InitList(IShellViewImpl *This)
}
}
+ list_font = (HFONT)SendMessageW(This->hWndList, WM_GETFONT, 0, 0);
+ list_dc = GetDC(This->hWndList);
+ old_font = SelectObject(list_dc, list_font);
+ GetTextMetricsW(list_dc, &tm);
+ SelectObject(list_dc, old_font);
+ ReleaseDC(This->hWndList, list_dc);
+
for (This->columns = 0;; This->columns++)
{
if (This->pSF2Parent)
@@ -415,9 +425,9 @@ static void ShellView_InitList(IShellViewImpl *This)
if (FAILED(hr)) break;
lvColumn.fmt = sd.fmt;
- lvColumn.cx = sd.cxChar*8; /* chars->pixel */
- StrRetToStrNW(nameW, sizeof(nameW)/sizeof(WCHAR), &sd.str, NULL);
- SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
+ lvColumn.cx = MulDiv(sd.cxChar, tm.tmAveCharWidth * 3, 2); /* chars->pixel */
+ StrRetToStrNW(nameW, sizeof(nameW)/sizeof(WCHAR), &sd.str, NULL);
+ SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
}
if (details) IShellDetails_Release(details);
More information about the wine-cvs
mailing list