Commit d495cc37 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

comdlg32: Expand the filetype combobox dropdown to fit the contents.

parent dc7f17ee
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment