ComboBox num visible items

ComboBox num visible items

Post by IceD » Sun, 25 May 2008 03:24:14


Hello!

CB_SETMINVISIBLE is not supported under windows ce. The only way, I
have found is to use CB_GETITEMHEIGHT to get height of combo itself
and item element. However, setting combo box height to comboHeight +
numVisible * itemHeight isn't accurate - sometimes one more item is
visible. Any suggestions?

Best,
Andrew.
 
 
 

ComboBox num visible items

Post by IceD » Sun, 25 May 2008 06:48:24

Hello!

Answering my own question:

void ComboBox::ResizeListBox() {
int numVisibleItems = this->numVisibleItems;
if (GetNumItems() < numVisibleItems) {
numVisibleItems = GetNumItems();
}

int itemHeight = (int)SendMessage(hWnd, CB_GETITEMHEIGHT,
(WPARAM)0, NULL);

COMBOBOXINFO cbi;
cbi.cbSize = sizeof(COMBOBOXINFO);
SendMessage(hWnd, CB_GETCOMBOBOXINFO, NULL, (LPARAM)&cbi);

RECT rc;
GetClientRect(cbi.hwndList, &rc);
rc.bottom = rc.top + itemHeight * numVisibleItems;

MoveWindow(cbi.hwndList, rc.left, rc.top, rc.right - rc.left,
rc.bottom - rc.top + GetHorizontalBorderWidth() * 2, FALSE);
}

This method does the trick. Awfull.

Best,
Andrew.