wgt_string_size(win, "00", &textsz);
max_width = width < 0 && width != WGT_AUTO ? -width : textsz.width;
+ /* first get the height of the editbox */
sum_height = SendMessage(cbwnd, CB_GETITEMHEIGHT, -1, 0);
sz->y = sum_height;
-
- for(i=0; i<num_items; i++) {
- wgt_string_size(win, items[i], &textsz);
- if(textsz.width > max_width) max_width = textsz.width;
- sum_height += SendMessage(cbwnd, CB_GETITEMHEIGHT, i, 0);
+ /* then add the height of the dropdown list items */
+ /* XXX I can't figure out why, but it's not sufficient to show all items
+ * without some more height, so let's double it...
+ */
+ sum_height *= 2;
+ sum_height += SendMessage(cbwnd, CB_GETITEMHEIGHT, 0, 0) * num_items;
+ sum_height += GetSystemMetrics(SM_CYEDGE) * 2;
+
+ if(width < 0) {
+ int sbar_width;
+ for(i=0; i<num_items; i++) {
+ wgt_string_size(win, items[i], &textsz);
+ if(textsz.width > max_width) max_width = textsz.width;
+ }
+ sbar_width = GetSystemMetrics(SM_CXVSCROLL);
+ width = max_width + sbar_width + GetSystemMetrics(SM_CXEDGE) * 2;
}
- if(width < 0) width = max_width * 3 / 2;
if(height < 0) height = sum_height;
sz->width = width;
SendMessage(w->handle, CB_SETCURSEL, sel, 0);
}
-
w->cb_modify = modfunc;
w->next = win->wlist;
win->wlist = w;
combosize(w->win, w->handle, items, num_items, w->rect.width, WGT_AUTO, &size);
MoveWindow(w->handle, w->rect.x, w->rect.y, w->rect.width, size.height, TRUE);
+
+ SendMessage(w->handle, CB_SETCURSEL, 0, 0);
return 0;
}