Module: wine Branch: master Commit: d495cc37a676eaafd3af5585adf2bf012b7cceda URL: http://source.winehq.org/git/wine.git/?a=commit;h=d495cc37a676eaafd3af5585ad...
Author: David Hedberg david.hedberg@gmail.com Date: Wed Sep 3 22:58:28 2014 +0200
comdlg32: Expand the filetype combobox dropdown to fit the contents.
---
dlls/comdlg32/comdlg32.rc | 2 +- dlls/comdlg32/itemdlg.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/comdlg32/comdlg32.rc b/dlls/comdlg32/comdlg32.rc index 3118610..d3deeab 100644 --- a/dlls/comdlg32/comdlg32.rc +++ b/dlls/comdlg32/comdlg32.rc @@ -487,7 +487,7 @@ FONT 8, "MS Shell Dlg" EDITTEXT IDC_FILENAME, 226, 240, 100, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP
LTEXT "Files of type:", IDC_FILETYPESTATIC, 160, 256, 60, 9, SS_RIGHT - COMBOBOX IDC_FILETYPE, 226, 256, 100, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP | + COMBOBOX IDC_FILETYPE, 226, 256, 100, 12, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_HASSTRINGS | CBS_DROPDOWNLIST
DEFPUSHBUTTON "&Open", IDOK, 350, 240, 40, 14, WS_GROUP diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c index 0426488..3b97111 100644 --- a/dlls/comdlg32/itemdlg.c +++ b/dlls/comdlg32/itemdlg.c @@ -1535,10 +1535,32 @@ static LRESULT on_wm_initdialog(HWND hwnd, LPARAM lParam) hitem = GetDlgItem(This->dlg_hwnd, IDC_FILETYPE); if(This->filterspec_count) { - UINT i; + HDC hdc; + HFONT font; + SIZE size; + UINT i, maxwidth = 0; + + hdc = GetDC(hitem); + font = (HFONT)SendMessageW(hitem, WM_GETFONT, 0, 0); + SelectObject(hdc, font); + for(i = 0; i < This->filterspec_count; i++) + { SendMessageW(hitem, CB_ADDSTRING, 0, (LPARAM)This->filterspecs[i].pszName);
+ if(GetTextExtentPoint32W(hdc, This->filterspecs[i].pszName, lstrlenW(This->filterspecs[i].pszName), &size)) + maxwidth = max(maxwidth, size.cx); + } + ReleaseDC(hitem, hdc); + + if(maxwidth > 0) + { + maxwidth += GetSystemMetrics(SM_CXVSCROLL) + 4; + SendMessageW(hitem, CB_SETDROPPEDWIDTH, (WPARAM)maxwidth, 0); + } + else + ERR("Failed to calculate width of filetype dropdown\n"); + SendMessageW(hitem, CB_SETCURSEL, This->filetypeindex, 0); } else