Toolbar buttons won't adjust its size to fit the DPI setting. This two patches set a DPI-considered size to those buttons to make them look better in HiDPI.
Here are some comparisons on Wine with 192 DPI:

vs


vs

-- v2: comdlg32: Set a size for toolbar buttons of the file access dialog. comdlg32: Calculate button height of toolbar with DPI for item dialog.
From: Jactry Zeng jzeng@codeweavers.com
--- dlls/comdlg32/itemdlg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 95778c2f358..e6f4ecb55b9 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -1896,6 +1896,7 @@ static void init_toolbar(FileDialogImpl *This, HWND hwnd) HWND htoolbar; TBADDBITMAP tbab; TBBUTTON button[2]; + int height;
htoolbar = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL, TBSTYLE_FLAT | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, @@ -1920,7 +1921,8 @@ static void init_toolbar(FileDialogImpl *This, HWND hwnd) button[1].iString = 0;
SendMessageW(htoolbar, TB_ADDBUTTONSW, 2, (LPARAM)button); - SendMessageW(htoolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(24,24)); + height = MulDiv(24, This->dpi_y, USER_DEFAULT_SCREEN_DPI); + SendMessageW(htoolbar, TB_SETBUTTONSIZE, 0, MAKELPARAM(height, height)); SendMessageW(htoolbar, TB_AUTOSIZE, 0, 0); }
From: Jactry Zeng jzeng@codeweavers.com
The default size is too small for HiDPI, so set the same height as the look-in combo box to it. And since in owner draw mode, the height of combo box is calculated and updated when drawing items, this patch set button height for toolbar from FILEDLG95_LOOKIN_DrawItem() too. --- dlls/comdlg32/filedlg.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 415c0580461..acb9b4f35a4 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -180,7 +180,7 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd);
/* Functions used by the Look In combo box */ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo); -static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct); +static LRESULT FILEDLG95_LOOKIN_DrawItem(HWND hwnd, LPDRAWITEMSTRUCT pDIStruct); static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode); static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId); static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod); @@ -1392,7 +1392,7 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l switch(((LPDRAWITEMSTRUCT)lParam)->CtlID) { case IDC_LOOKIN: - FILEDLG95_LOOKIN_DrawItem((LPDRAWITEMSTRUCT) lParam); + FILEDLG95_LOOKIN_DrawItem(hwnd, (LPDRAWITEMSTRUCT)lParam); return TRUE; } } @@ -3368,13 +3368,12 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo) * * WM_DRAWITEM message handler */ -static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct) +static LRESULT FILEDLG95_LOOKIN_DrawItem(HWND hwnd, LPDRAWITEMSTRUCT pDIStruct) { COLORREF crWin = GetSysColor(COLOR_WINDOW); COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT); COLORREF crText = GetSysColor(COLOR_WINDOWTEXT); - RECT rectText; - RECT rectIcon; + RECT rectText, rectIcon, lookin_rect; SHFILEINFOW sfi; HIMAGELIST ilItemImage; int iIndentation; @@ -3382,6 +3381,8 @@ static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct) LPSFOLDER tmpFolder; UINT shgfi_flags = SHGFI_PIDL | SHGFI_OPENICON | SHGFI_SYSICONINDEX | SHGFI_DISPLAYNAME; UINT icon_width, icon_height; + FileOpenDlgInfos *dialog; + int height;
TRACE("\n");
@@ -3452,6 +3453,12 @@ static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct)
/* Draw the associated text */ TextOutW(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,lstrlenW(sfi.szDisplayName)); + + dialog = get_filedlg_infoptr(hwnd); + GetWindowRect(dialog->DlgInfos.hwndLookInCB, &lookin_rect); + height = lookin_rect.bottom - lookin_rect.top; + SendMessageW(dialog->DlgInfos.hwndTB, TB_SETBUTTONSIZE, 0, MAKELPARAM(height, height)); + return NOERROR; }
On Fri May 19 16:34:48 2023 +0000, Esme Povirk wrote:
I see, even at the default DPI, the toolbar window is significantly larger than the toolbar is visually. But the "Look in" label control is not as tall as the combo box (which sizes itself automatically, ignoring the height in the dialog template), and to me it doesn't seem to line up. My suggestion would be to use GetComboBoxInfo to find the height of the combo box's drop-down arrow.
OK, I didn't recognize that sizes of the combo box and its controls aren't fixed after the initialization, they can be changed when drawing items. This is why I got buttons much higher than combo box when I try to set the same height for toolbar buttons from FILEDLG95_InitControls(). In v2, I try another approach which setting size of toolbar buttons from FILEDLG95_LOOKIN_DrawItem(). It looks much better now:
with 96 dpi:

with 192 dpi:

Thanks
This merge request was approved by Esme Povirk.