-
Problem with Combo Box
Can't get a combo box to display its content. If I query for its content, it seems to be working fine. CB_GETCOUNT returns the correct number, for example. I'm not sure what to make of it...
Code:
DLG_MASTERCONFIGURE DIALOG 0, 0, 260, 140
.....
BEGIN
.....
COMBOBOX IDCMB_SCREENNUM, 18, 88, 35, 13, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL
.....
END
Code:
case WM_INITDIALOG:
{
int si;
char ScreenNum[3];
for(si = 1; si <= NumberOfScreens; ++si)
{
snprintf(ScreenNum, 3, "%i", si);
SendDlgItemMessage(hDlg, IDCMB_SCREENNUM, CB_ADDSTRING, 0, (LPARAM)ScreenNum);
}
}
break;
-
Because the combobox is too small (the height). Try to change to:
Code:
COMBOBOX IDCMB_SCREENNUM,18,88,35,100,CBS_DROPDOWNLIST|CBS_SORT|WS_VSCROLL
Now it will expand the list since 100px height, and if there's more items it will also show a vertical scroll bar.
Hope that helps
Niara
-
Ah, you can also set the first item selected using:
Code:
SendDlgItemMessage(hwnd,IDCMB_SCREENNUM,CB_SETCURSEL,(WPARAM)0,0);
Niara
-
The height corresponds to the list portion? That's annoying. Thanks for the tip.
-
Yes, the height in that case it corresponds to the max height that the expanded list can have. So if you set a height of 100px and 3 items to show each of 25px, it will show a list of 3*25px, but if you have 5 items it will show a list of 100px with a vertical scroll (if you have defined that the control can have a vscroll, of course). Or that's how I understand that, if it's wrong please correct :)
Niara